java.security.cert.X509Certificate.getNotAfter()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(562)

本文整理了Java中java.security.cert.X509Certificate.getNotAfter()方法的一些代码示例,展示了X509Certificate.getNotAfter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。X509Certificate.getNotAfter()方法的具体详情如下:
包路径:java.security.cert.X509Certificate
类名称:X509Certificate
方法名:getNotAfter

X509Certificate.getNotAfter介绍

[英]Returns the notAfter date of the validity period of the certificate.
[中]返回证书有效期之后的日期。

代码示例

代码示例来源:origin: Meituan-Dianping/walle

@Override
public Date getNotAfter() {
  return mDelegate.getNotAfter();
}

代码示例来源:origin: robovm/robovm

public Date getNotAfter() {
  return cert.getNotAfter();
}

代码示例来源:origin: knowm/XChange

private boolean certificateMatches(X509Certificate[] certs, boolean needsToBeExpired) {
 for (X509Certificate cert : certs)
  if (cert.getSubjectX500Principal().getName().equals(subjectPrincipalName)
    && (!needsToBeExpired || cert.getNotAfter().before(new Date()))) return true;
 return false;
}

代码示例来源:origin: redisson/redisson

@Override
public Date getNotAfter() {
  return unwrap().getNotAfter();
}

代码示例来源:origin: wildfly/wildfly

@Override
public Date getNotAfter() {
  return unwrap().getNotAfter();
}

代码示例来源:origin: commonsguy/cw-omnibus

private SigModel(X509Certificate cert) {
  this.subject=cert.getSubjectDN().toString();
  this.issuer=cert.getIssuerDN().toString();
  this.validDates=
   FORMAT.format(cert.getNotBefore())+" to "+
    FORMAT.format(cert.getNotAfter());
 }
}

代码示例来源:origin: skylot/jadx

public String generateHeader() {
  StringBuilder builder = new StringBuilder();
  append(builder, NLS.str("certificate.cert_type"), x509cert.getType());
  append(builder, NLS.str("certificate.serialSigVer"), ((Integer) x509cert.getVersion()).toString());
  // serial number
  append(builder, NLS.str("certificate.serialNumber"), "0x" + x509cert.getSerialNumber().toString(16));
  // Get subject
  Principal subjectDN = x509cert.getSubjectDN();
  append(builder, NLS.str("certificate.cert_subject"), subjectDN.getName());
  append(builder, NLS.str("certificate.serialValidFrom"), x509cert.getNotBefore().toString());
  append(builder, NLS.str("certificate.serialValidUntil"), x509cert.getNotAfter().toString());
  return builder.toString();
}

代码示例来源:origin: igniterealtime/Openfire

final Date notAfter = certificate.getNotAfter();
if (earliestNotAfter == null || ( notAfter != null && notAfter.before( earliestNotAfter ) ) )

代码示例来源:origin: jenkinsci/jenkins

/**
 * {@inheritDoc}
 */
@Override
public void handle(Socket socket) throws IOException, InterruptedException {
  try {
    X509Certificate certificate = (X509Certificate) keyStore.getCertificate("jenkins");
    if (certificate == null
        || certificate.getNotAfter().getTime() < System.currentTimeMillis() + TimeUnit.DAYS.toMillis(1)) {
      LOGGER.log(Level.INFO, "Updating {0} TLS certificate to retain validity", getName());
      X509Certificate identityCertificate = InstanceIdentityProvider.RSA.getCertificate();
      RSAPrivateKey privateKey = InstanceIdentityProvider.RSA.getPrivateKey();
      char[] password = "password".toCharArray();
      keyStore.setKeyEntry("jenkins", privateKey, password, new X509Certificate[]{identityCertificate});
    }
  } catch (KeyStoreException e) {
    LOGGER.log(Level.FINEST, "Ignored", e);
  }
  handler.handle(socket,
      Collections.singletonMap(JnlpConnectionState.COOKIE_KEY, JnlpAgentReceiver.generateCookie()),
      ExtensionList.lookup(JnlpAgentReceiver.class));
}

代码示例来源:origin: stackoverflow.com

173           Date now = new Date();
174           if (lastCertificate.getSubjectDN().equals(lastCertificate.getIssuerDN())
175               && now.after(lastCertificate.getNotAfter())) {
176             --chainLength;
177           }

代码示例来源:origin: stackoverflow.com

Date now = new Date();
if (lastCertificate.getSubjectDN().equals(lastCertificate.getIssuerDN())
    && now.after(lastCertificate.getNotAfter()))

代码示例来源:origin: ankidroid/Anki-Android

Date now = new Date();
if (lastCertificate.getSubjectDN().equals(lastCertificate.getIssuerDN())
    && now.after(lastCertificate.getNotAfter())) {
  --chainLength;

代码示例来源:origin: igniterealtime/Openfire

certs.append(x509cert.getNotBefore());
certs.append("\nNot After: ");
certs.append(x509cert.getNotAfter());
certs.append("\n\n-----BEGIN CERTIFICATE-----\n");
certs.append(DatatypeConverter.printBase64Binary(

代码示例来源:origin: blynkkk/blynk-server

@Override
public void run() {
  try {
    if (AcmeClient.DOMAIN_CHAIN_FILE.exists()) {
      //stream closed inside utilities method
      X509Certificate cert = readX509Certificate();
      Date expirationDate = cert.getNotAfter();
      long daysToExpire = getDateDiff(expirationDate);
      log.info("Certificate expiration date is {}. Days left : {}", expirationDate, daysToExpire);
      if (daysToExpire <= renewBeforeDays) {
        renew();
      }
    } else {
      renew();
    }
  } catch (Exception e) {
    log.error("Error during certificate renewal.", e);
  }
}

代码示例来源:origin: igniterealtime/Openfire

Log.debug( "   length: " + chain.length );
for (int i=0; i<chain.length; i++) {
  Log.debug( " Certificate[{}] (valid from {} to {}):", i, chain[ i ].getNotBefore(), chain[ i ].getNotAfter() );
  Log.debug( "   subjectDN: " + chain[ i ].getSubjectDN() );
  Log.debug( "   issuerDN: " + chain[ i ].getIssuerDN() );

代码示例来源:origin: blynkkk/blynk-server

certificate.writeCertificate(fw);
log.info("Overriding certificate. Expiration date is : {}", certificate.getCertificate().getNotAfter());

代码示例来源:origin: io.netty/netty-handler

@Override
public Date getNotAfter() {
  return unwrap().getNotAfter();
}

代码示例来源:origin: hsiafan/apk-parser

public static CertificateMeta from(X509Certificate certificate) throws CertificateEncodingException {
  byte[] bytes = certificate.getEncoded();
  String certMd5 = md5Digest(bytes);
  String publicKeyString = byteToHexString(bytes);
  String certBase64Md5 = md5Digest(publicKeyString);
  return new CertificateMeta(
      certificate.getSigAlgName().toUpperCase(),
      certificate.getSigAlgOID(),
      certificate.getNotBefore(),
      certificate.getNotAfter(),
      bytes, certBase64Md5, certMd5);
}

代码示例来源:origin: psi-probe/psi-probe

/**
 * Adds the to store.
 *
 * @param certs the certs
 * @param alias the alias
 * @param x509Cert the x509 cert
 */
private void addToStore(List<Cert> certs, String alias, X509Certificate x509Cert) {
 Cert cert = new Cert();
 cert.setAlias(alias);
 cert.setSubjectDistinguishedName(x509Cert.getSubjectDN().toString());
 cert.setNotBefore(x509Cert.getNotBefore());
 cert.setNotAfter(x509Cert.getNotAfter());
 cert.setIssuerDistinguishedName(x509Cert.getIssuerDN().toString());
 certs.add(cert);
}

代码示例来源:origin: apache/cloudstack

@Test
public void testCertificateConversionMethods() throws Exception {
  final X509Certificate in = caCertificate;
  final String pem = CertUtils.x509CertificateToPem(in);
  final X509Certificate out = CertUtils.pemToX509Certificate(pem);
  Assert.assertTrue(pem.startsWith("-----BEGIN CERTIFICATE-----\n"));
  Assert.assertTrue(pem.endsWith("-----END CERTIFICATE-----\n"));
  Assert.assertEquals(in.getSerialNumber(), out.getSerialNumber());
  Assert.assertArrayEquals(in.getSignature(), out.getSignature());
  Assert.assertEquals(in.getSigAlgName(), out.getSigAlgName());
  Assert.assertEquals(in.getPublicKey(), out.getPublicKey());
  Assert.assertEquals(in.getNotBefore(), out.getNotBefore());
  Assert.assertEquals(in.getNotAfter(), out.getNotAfter());
  Assert.assertEquals(in.getIssuerDN().toString(), out.getIssuerDN().toString());
}

相关文章