We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to Get Certificate Valid 'from' and 'to' Dates using Java | X509Certificate2Wrapper

I can extract basic signing information such as signing time and certificate issuer by below code.

Document doc = new Document(...);
for (DigitalSignature signature : doc.getDigitalSignatures()) {
	System.out.println("Sign date = " + signature.getSignTime());
	System.out.println("Reason = " + signature.getComments());
	System.out.println("Issuer name = " + signature.getIssuerName());

But how about detail certificate information, such that the certificate valid period, etc.


cert_info.gif (22.3 KB)


Unfortunately, Aspose.Words does not provide API to get the valid from and to dates of certificate. We have logged this feature request as WORDSNET-22429 in our issue tracking system. We will inform you via this forum thread once there is an update available on it.

We apologize for your inconvenience.


We have added X509Certificate2Wrapper.getJavaCertificateInfo() method in Aspose.Words 21.8. You can get all possible fields from the returned java.security.cert.X509Certificate. You can use following code example once next version of Aspose.Words 21.8 is available. We will inform you via this forum thread once new version of Aspose.Words for Java is released.

Document doc = new Document("SignedDoc.docx");
for (DigitalSignature signature : doc.getDigitalSignatures())
    Date signTime = signature.getSignTime();
    String comments = signature.getComments();
    String issuerName = signature.getIssuerName();

    X509Certificate2Wrapper certificateWrapper = signature.getCertificateHolder().getCertificate();
    X509Certificate certificateInfo = certificateWrapper.getJavaCertificateInfo(); //the new public member

    Date notBefore = certificateInfo.getNotBefore();
    Date notAfter = certificateInfo.getNotAfter();
    String sigAlgName = certificateInfo.getSigAlgName();
    String sigAlgOID = certificateInfo.getSigAlgOID();
    BigInteger serialNumber = certificateInfo.getSerialNumber();
    Principal issuerDN = certificateInfo.getIssuerDN();
    Principal subjectDN = certificateInfo.getSubjectDN();