pdf-box 라이브러리 (v2.0.8)를 사용하여 pdf 문서에 디지털 서명을 추가하려고합니다. 웹 서비스 (서명 된 개인 키로 만 서명)에서 이미 서명 된 콘텐츠를 받고 있습니다. 이제 서명 된 데이터에 인증서 정보를 연결하여 PDF 문서에 추가 할 수 있어야합니다. 가급적 성기 성 API를 사용하여 이미 서명 된 콘텐츠에 인증서를 추가하는 방법은 무엇입니까?이미 서명 된 데이터에 인증서 정보를 연결하는 방법은 무엇입니까?
// here content is data which has to be signed
public byte[] sign(InputStream content) throws IOException {
try {
CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
List<Certificate> certList = new ArrayList<Certificate>();
certList.add(certificate);
Store certs = new JcaCertStore(certList);
gen.addCertificates(certs);
CMSProcessableInputStream msg = new CMSProcessableInputStream(signPrivate(content));
CMSSignedData signedData = gen.generate(msg, false);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DEROutputStream dos = new DEROutputStream(baos);
dos.writeObject(signedData.toASN1Structure());
return baos.toByteArray();
} catch (Exception e) {
throw new IOException(e);
}
}
여기서 디지털 서명을 생성 할 수 있지만 인증서 정보는 포함되어 있지 않습니다. 이미 this과 this 질문을 확인했지만 콘텐츠가 이미 개인 키를 사용하여 seperatly로 서명되어 있고 인증서 만 연결해야하는 경우는 없습니다.
심각하게 받아 들여지는 모든 CMS 서명 프로파일에서 해당 인증서에 대한 참조가 서명 된 데이터가 서명되기 전에 * 해당 인증서가 필요합니다. – mkl
@mkl, 나중에 인증서를 연결할 수 없으며 개인 키로 콘텐츠에 서명 할 때만 할 수 있다고 말씀 하시겠습니까? –