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

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

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

X509Certificate.getNotBefore介绍

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

代码示例

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

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

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

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

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

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

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

public Date getCertificateNotBeforeDate() {
  return getFirstCertificate().getNotBefore();
}

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

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

代码示例来源: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 notBefore = certificate.getNotBefore();
if (latestNotBefore == null || ( notBefore != null && notBefore.after( latestNotBefore ) ) )

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

certs.append(x509cert.getNotBefore());
certs.append("\nNot After: ");
certs.append(x509cert.getNotAfter());

代码示例来源: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: io.netty/netty-handler

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

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

private void printCertificateChain(final X509Certificate[] certificates, final String s) throws CertificateException {
  if (certificates == null) {
    return;
  }
  final StringBuilder builder = new StringBuilder();
  builder.append("A client/agent attempting connection from address=").append(clientAddress).append(" has presented these certificate(s):");
  int counter = 1;
  for (final X509Certificate certificate: certificates) {
    builder.append("\nCertificate [").append(counter++).append("] :");
    builder.append(String.format("\n Serial: %x", certificate.getSerialNumber()));
    builder.append("\n  Not Before:" + certificate.getNotBefore());
    builder.append("\n  Not After:" + certificate.getNotAfter());
    builder.append("\n  Signature Algorithm:" + certificate.getSigAlgName());
    builder.append("\n  Version:" + certificate.getVersion());
    builder.append("\n  Subject DN:" + certificate.getSubjectDN());
    builder.append("\n  Issuer DN:" + certificate.getIssuerDN());
    builder.append("\n  Alternative Names:" + certificate.getSubjectAlternativeNames());
  }
  LOG.debug(builder.toString());
}

代码示例来源:origin: i2p/i2p.i2p

/**
 *  Modified from http://blogs.sun.com/andreas/resource/InstallCert.java
 *  @since 0.8.2
 */
private static void saveCerts(String host, SavingTrustManager stm) {
  X509Certificate[] chain = stm.chain;
  if (chain == null) {
    System.out.println("Could not obtain server certificate chain");
    return;
  }
  for (int k = 0; k < chain.length; k++) {
    X509Certificate cert = chain[k];
    String name = host + '-' + (k + 1) + ".crt";
    System.out.println("NOTE: Saving X509 certificate as " + name);
    System.out.println("      Issuer:     " + cert.getIssuerX500Principal());
    System.out.println("      Valid From: " + cert.getNotBefore());
    System.out.println("      Valid To:   " + cert.getNotAfter());
    try {
      cert.checkValidity();
    } catch (GeneralSecurityException e) {
      System.out.println("      WARNING: Certificate is not currently valid, it cannot be used");
    }
    CertUtil.saveCert(cert, new File(name));
  }
  System.out.println("NOTE: To trust them, copy the certificate file(s) to the certificates directory and rerun without the -s option");
}

代码示例来源: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: i2p/i2p.i2p

" Issuer: " + cert.getIssuerX500Principal() +
       " Serial: " + cert.getSerialNumber().toString(16) +
       "; Valid From: " + cert.getNotBefore() +
       " To: " + cert.getNotAfter());
if (cs != null && CertUtil.isRevoked(cs, 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());
}

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

private boolean isBeforeNotBefore() {
  Date today = new Date();
  if (today.before(certificate.getNotBefore())) {
    return true;
  } else {
    return false;
  }
}

代码示例来源:origin: rancher/cattle

public static String getIssuedDate(String certInput) throws Exception {
  X509Certificate cert = getCertificateFromPem(certInput);
  return cert.getNotBefore().toString();
}

代码示例来源:origin: com.axway.ats.framework/ats-core

private String printCertificateInfo( X509Certificate cert ) {
  StringBuffer sb = new StringBuffer();
  sb.append("  Checking SSL Server certificate :\n")
   .append("  Subject DN: " + cert.getSubjectDN() + "\n")
   .append("  Signature Algorithm: " + cert.getSigAlgName() + "\n")
   .append("  Valid from: " + cert.getNotBefore() + "\n")
   .append("  Valid until: " + cert.getNotAfter() + "\n")
   .append("  Issuer: " + cert.getIssuerDN() + "\n");
  return sb.toString();
}

相关文章