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

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

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

X509Certificate.getIssuerDN介绍

[英]Returns the issuer (issuer distinguished name) as an implementation specific Principal object.

The ASN.1 definition of issuer:

issuer      Name 
Name ::= CHOICE { 
RDNSequence } 
RDNSequence ::= SEQUENCE OF RelativeDistinguishedName 
RelativeDistinguishedName ::= SET OF AttributeTypeAndValue 
AttributeTypeAndValue ::= SEQUENCE { 
type     AttributeType, 
value    AttributeValue } 
AttributeType ::= OBJECT IDENTIFIER 
AttributeValue ::= ANY DEFINED BY AttributeType

replaced by: #getIssuerX500Principal().
[中]将颁发者(颁发者可分辨名称)作为特定于实现的主体对象返回。
ASN。1发行人的定义:

issuer      Name 
Name ::= CHOICE { 
RDNSequence } 
RDNSequence ::= SEQUENCE OF RelativeDistinguishedName 
RelativeDistinguishedName ::= SET OF AttributeTypeAndValue 
AttributeTypeAndValue ::= SEQUENCE { 
type     AttributeType, 
value    AttributeValue } 
AttributeType ::= OBJECT IDENTIFIER 
AttributeValue ::= ANY DEFINED BY AttributeType

替换为:#getIssuerX500Principal()。

代码示例

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

private String describeCertificate( X509Certificate certificate )
{
  return "Subject: " + certificate.getSubjectDN() +
      ", Issuer: " + certificate.getIssuerDN();
}

代码示例来源:origin: square/okhttp

/** Returns true if {@code toVerify} was signed by {@code signingCert}'s public key. */
private boolean verifySignature(X509Certificate toVerify, X509Certificate signingCert) {
 if (!toVerify.getIssuerDN().equals(signingCert.getSubjectDN())) return false;
 try {
  toVerify.verify(signingCert.getPublicKey());
  return true;
 } catch (GeneralSecurityException verifyFailed) {
  return false;
 }
}

代码示例来源:origin: prestodb/presto

/** Returns true if {@code toVerify} was signed by {@code signingCert}'s public key. */
private boolean verifySignature(X509Certificate toVerify, X509Certificate signingCert) {
 if (!toVerify.getIssuerDN().equals(signingCert.getSubjectDN())) return false;
 try {
  toVerify.verify(signingCert.getPublicKey());
  return true;
 } catch (GeneralSecurityException verifyFailed) {
  return false;
 }
}

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

private static boolean issuedBy(final X509Certificate certificate, X509Certificate issuer) {
  if (issuer.getSubjectDN().equals(certificate.getIssuerDN())) {
    try {
      certificate.verify(issuer.getPublicKey());
      return true;
    } catch (Exception e) {
      return false;
    }
  }
  return false;
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

/** Returns true if {@code toVerify} was signed by {@code signingCert}'s public key. */
private boolean verifySignature(X509Certificate toVerify, X509Certificate signingCert) {
 if (!toVerify.getIssuerDN().equals(signingCert.getSubjectDN())) return false;
 try {
  toVerify.verify(signingCert.getPublicKey());
  return true;
 } catch (GeneralSecurityException verifyFailed) {
  return false;
 }
}

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

private static X509Certificate[] createChain(X509Certificate  signer, X509Certificate[] candidates) {
  LinkedList chain = new LinkedList();
  chain.add(0, signer);
  // Signer is self-signed
  if (signer.getSubjectDN().equals(signer.getIssuerDN())){
    return (X509Certificate[])chain.toArray(new X509Certificate[1]);
  }
  Principal issuer = signer.getIssuerDN();
  X509Certificate issuerCert;
  int count = 1;
  while (true) {
    issuerCert = findCert(issuer, candidates);
    if( issuerCert == null) {
      break;
    }
    chain.add(issuerCert);
    count++;
    if (issuerCert.getSubjectDN().equals(issuerCert.getIssuerDN())) {
      break;
    }
    issuer = issuerCert.getIssuerDN();
  }
  return (X509Certificate[])chain.toArray(new X509Certificate[count]);
}

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

172           X509Certificate lastCertificate = serverCertificates[chainLength - 1];
173           Date now = new Date();
174           if (lastCertificate.getSubjectDN().equals(lastCertificate.getIssuerDN())
175               && now.after(lastCertificate.getNotAfter())) {
176             --chainLength;

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

X509Certificate x509Cert = (X509Certificate) certFactory.generateCertificate(certStream);
sb.append("Certificate subject: " + x509Cert.getSubjectDN() + "<br>");
sb.append("Certificate issuer: " + x509Cert.getIssuerDN() + "<br>");
sb.append("Certificate serial number: " + x509Cert.getSerialNumber() + "<br>");
sb.append("<br>");

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

warning = FormValidation.warning(e,String.format("Certificate %s is not yet valid in %s",cert.toString(),name));
LOGGER.log(Level.FINE, "Add certificate found in json doc: \r\n\tsubjectDN: {0}\r\n\tissuer: {1}", new Object[]{c.getSubjectDN(), c.getIssuerDN()});
certs.add(c);

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

final Principal issuer = certificate.getIssuerDN();
  final Principal subject = certificate.getSubjectDN();
X509Certificate next = bySubject.remove( first.getIssuerDN() );
while (next != null) {
  orderedResult.add( next );
  next = bySubject.remove( next.getIssuerDN() );

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

boolean foundNext = false;
  for (int nextIndex = currIndex + 1; nextIndex < certificates.length; ++nextIndex) {
    if (certificates[currIndex].getIssuerDN().equals(certificates[nextIndex].getSubjectDN())) {
      foundNext = true;
X509Certificate lastCertificate = certificates[chainLength - 1];
Date now = new Date();
if (lastCertificate.getSubjectDN().equals(lastCertificate.getIssuerDN())
    && now.after(lastCertificate.getNotAfter())) {
  --chainLength;

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

++nextIndex) 
  if (certificates[currIndex].getIssuerDN().equals(
         certificates[nextIndex].getSubjectDN())) 
X509Certificate lastCertificate = certificates[chainLength - 1];
Date now = new Date();
if (lastCertificate.getSubjectDN().equals(lastCertificate.getIssuerDN())
    && now.after(lastCertificate.getNotAfter()))

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

for ( int i = 0; i < chain.length; i++ ) {
  X509Certificate cert = chain[i];
  LOG.debug( " " + ( i + 1 ) + " Subject " + cert.getSubjectDN() );
  LOG.debug( "   Issuer  " + cert.getIssuerDN() );
  sha1.update( cert.getEncoded() );
  LOG.debug( "   sha1    " + toHexString( sha1.digest() ) );

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

if ( cert.getSubjectDN().equals( cert.getIssuerDN() ) )
    Log.debug( "   - " + acceptedIssuer.getSubjectDN() + "/" + acceptedIssuer.getIssuerDN() );
  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() );
      if ( acceptedIssuer.getIssuerDN().equals( chain[i].getIssuerDN() ) ) {
        Log.debug( "Found accepted issuer with same DN: " + acceptedIssuer.getIssuerDN() );

代码示例来源:origin: k9mail/k-9

chainInfo.append("Subject: ").append(chain[i].getSubjectDN().toString()).append("\n");
chainInfo.append("Issuer: ").append(chain[i].getIssuerDN().toString()).append("\n");
if (sha1 != null) {
  sha1.reset();

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

if (certs != null && certs.length > 0) {
  final X509Certificate cert = certs[0];
  subjectDn = cert.getSubjectDN().getName();
  final String issuerDn = cert.getIssuerDN().getName();

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

for (int i = nSize -1; i >= 0 ; i--) {
  X509Certificate x509certificate = x509Certificates[i];
  Principal principalIssuer = x509certificate.getIssuerDN();
  Principal principalSubject = x509certificate.getSubjectDN();
  if (principalLast != null) {
    if (principalIssuer.equals(principalLast)) {
      break;
    } else {
      if(x509Certificates[nSize - 1].getIssuerDN().equals(tCert.getSubjectDN())) {
        try {
          PublicKey publickey = tCert.getPublicKey();
  throw new CertificateException("certificate path failed: Trusted CA is NULL");
} else {
  Log.debug("ClientTrustManager: Trusted CA: "+trustedCert.getSubjectDN());

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

X509Certificate cert = chain[i];
System.out.println
    (" " + (i + 1) + " Subject " + cert.getSubjectDN());
System.out.println("   Issuer  " + cert.getIssuerDN());
sha1.update(cert.getEncoded());
System.out.println("   sha1    " + toHexString(sha1.digest()));

相关文章