当前位置: 首页>>代码示例>>Java>>正文


Java CertificateParsingException.printStackTrace方法代码示例

本文整理汇总了Java中java.security.cert.CertificateParsingException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java CertificateParsingException.printStackTrace方法的具体用法?Java CertificateParsingException.printStackTrace怎么用?Java CertificateParsingException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.security.cert.CertificateParsingException的用法示例。


在下文中一共展示了CertificateParsingException.printStackTrace方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSubjectAlternativeNames

import java.security.cert.CertificateParsingException; //导入方法依赖的package包/类
public List<String> getSubjectAlternativeNames() {
	List<String> subjectAlternativeNames = new LinkedList<String>();

	try {
		if (certificate.getSubjectAlternativeNames() == null) {
			return subjectAlternativeNames;
		}

		for (List<?> i : certificate.getSubjectAlternativeNames()) {
			subjectAlternativeNames.add(i.get(1) + " (" + ObjectIdentifier.getSubjectAlternativeNames((Integer) i.get(0)) + ")");
		}
	} catch (CertificateParsingException e) {
		e.printStackTrace();
	}

	return subjectAlternativeNames;
}
 
开发者ID:SAMLRaider,项目名称:SAMLRaider,代码行数:18,代码来源:BurpCertificate.java

示例2: getIssuerAlternativeNames

import java.security.cert.CertificateParsingException; //导入方法依赖的package包/类
public List<String> getIssuerAlternativeNames() {
	List<String> issuerAlternativeNames = new LinkedList<String>();

	try {
		if (certificate.getIssuerAlternativeNames() == null) {
			return issuerAlternativeNames;
		}

		for (List<?> i : certificate.getIssuerAlternativeNames()) {
			issuerAlternativeNames.add(i.get(1) + " (" + ObjectIdentifier.getSubjectAlternativeNames((Integer) i.get(0)) + ")");
		}
	} catch (CertificateParsingException e) {
		e.printStackTrace();
	}

	return issuerAlternativeNames;
}
 
开发者ID:SAMLRaider,项目名称:SAMLRaider,代码行数:18,代码来源:BurpCertificate.java

示例3: getExtendedKeyUsage

import java.security.cert.CertificateParsingException; //导入方法依赖的package包/类
public List<String> getExtendedKeyUsage() {
	List<String> extendedKeyUsage = new LinkedList<>();

	try {
		if (certificate.getExtendedKeyUsage() == null) {
			return extendedKeyUsage;
		}

		for (String i : certificate.getExtendedKeyUsage()) {
			extendedKeyUsage.add(ObjectIdentifier.getExtendedKeyUsage(i));
		}
	} catch (CertificateParsingException e) {
		e.printStackTrace();
	}

	return extendedKeyUsage;
}
 
开发者ID:SAMLRaider,项目名称:SAMLRaider,代码行数:18,代码来源:BurpCertificate.java

示例4: getDNSSubjectAlts

import java.security.cert.CertificateParsingException; //导入方法依赖的package包/类
/**
 * Extracts the array of SubjectAlt DNS names from an X509Certificate.
 * Returns null if there aren't any.
 * <p/>
 * Note:  Java doesn't appear able to extract international characters
 * from the SubjectAlts.  It can only extract international characters
 * from the CN field.
 * <p/>
 * (Or maybe the version of OpenSSL I'm using to test isn't storing the
 * international characters correctly in the SubjectAlts?).
 *
 * @param cert X509Certificate
 * @return Array of SubjectALT DNS names stored in the certificate.
 */
public static String[] getDNSSubjectAlts(X509Certificate cert) {
    final List<String> subjectAltList = new LinkedList<String>();
    Collection<List<?>> c = null;
    try {
        c = cert.getSubjectAlternativeNames();
    }
    catch (CertificateParsingException cpe) {
        // Should probably log.debug() this?
        cpe.printStackTrace();
    }
    if (c != null) {
        Iterator<List<?>> it = c.iterator();
        while (it.hasNext()) {
            List<?> list = it.next();
            int type = ((Integer) list.get(0)).intValue();
            // If type is 2, then we've got a dNSName
            if (type == 2) {
                String s = (String) list.get(1);
                subjectAltList.add(s);
            }
        }
    }
    if (!subjectAltList.isEmpty()) {
        String[] subjectAlts = new String[subjectAltList.size()];
        subjectAltList.toArray(subjectAlts);
        return subjectAlts;
    } else {
        return null;
    }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:45,代码来源:SSLHostnameVerifier.java

示例5: getDNSSubjectAlts

import java.security.cert.CertificateParsingException; //导入方法依赖的package包/类
/**
 * Extract all alternative names from a certificate.
 * @param cert
 * @return
 */
private static String[] getDNSSubjectAlts(X509Certificate cert) {
	LinkedList subjectAltList = new LinkedList();
	Collection c = null;
	try {
		c = cert.getSubjectAlternativeNames();
	} catch (CertificateParsingException cpe) {
		// Should probably log.debug() this?
		cpe.printStackTrace();
	}
	if (c != null) {
		Iterator it = c.iterator();
		while (it.hasNext()) {
			List list = (List) it.next();
			int type = ((Integer) list.get(0)).intValue();
			// If type is 2, then we've got a dNSName
			if (type == 2) {
				String s = (String) list.get(1);
				subjectAltList.add(s);
			}
		}
	}
	if (!subjectAltList.isEmpty()) {
		String[] subjectAlts = new String[subjectAltList.size()];
		subjectAltList.toArray(subjectAlts);
		return subjectAlts;
	} else {
		return new String[0];
	}
        
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:36,代码来源:SSLProtocolSocketFactory.java

示例6: getTestCertificateObject

import java.security.cert.CertificateParsingException; //导入方法依赖的package包/类
public static X509CertificateObject getTestCertificateObject() {
    try {
        X509CertificateObject obj = new X509CertificateObject(getTestCertificate().getCertificateAt(0));
        return obj;
    } catch (CertificateParsingException ex) {
        ex.printStackTrace();
    }
    return null;
}
 
开发者ID:RUB-NDS,项目名称:TLS-Attacker,代码行数:10,代码来源:TestCertificates.java

示例7: showAcceptedIssuers

import java.security.cert.CertificateParsingException; //导入方法依赖的package包/类
private static void showAcceptedIssuers(X509Certificate[] acceptedIssuers, StringBuilder report) {
  for (int i = 0; i < acceptedIssuers.length; i++) {
    try {
      Collection<List<?>> subjectAlternativeNames = acceptedIssuers[i].getSubjectAlternativeNames();
      if (subjectAlternativeNames == null) {
        report.append(String.format("%d: %s (no subject alternatives))\n", i, acceptedIssuers[i].getSubjectX500Principal()));
      } else {
        report.append(String.format("%d: %s (%d subject alternatives)\n", i, acceptedIssuers[i].getSubjectX500Principal(), acceptedIssuers[i].getSubjectAlternativeNames().size()));
        for (List<?> x : subjectAlternativeNames) {
          int type = (Integer) x.get(0);
          String value = (String) x.get(1);
          switch (type) {
            case 2: // dNSName per RFC5280 4.2.1.6
              report.append(String.format("  subjectAlt: DNS:%s\n", value));
              break;
            case 7: // iPAddress per RFC5280 4.2.1.6
              report.append(String.format("  subjectAlt: IP:%s\n", value));
              break;
            default:
              report.append(String.format("  subjectAlt: [%d]:%s\n", type, value));
              break;
          }
        }
      }
    } catch (CertificateParsingException e) {
      e.printStackTrace();
    }
  }
}
 
开发者ID:elastic,项目名称:tealess,代码行数:30,代码来源:DiagnosticTLSObserver.java

示例8: getDNSSubjectAlts

import java.security.cert.CertificateParsingException; //导入方法依赖的package包/类
/**
 * Extracts the array of SubjectAlt DNS names from an X509Certificate.
 * Returns null if there aren't any.
 * <p/>
 * Note:  Java doesn't appear able to extract international characters
 * from the SubjectAlts.  It can only extract international characters
 * from the CN field.
 * <p/>
 * (Or maybe the version of OpenSSL I'm using to test isn't storing the
 * international characters correctly in the SubjectAlts?).
 *
 * @param cert X509Certificate
 * @return Array of SubjectALT DNS names stored in the certificate.
 */
public static String[] getDNSSubjectAlts(X509Certificate cert) {
    LinkedList subjectAltList = new LinkedList();
    Collection c = null;
    try {
        c = cert.getSubjectAlternativeNames();
    }
    catch (CertificateParsingException cpe) {
        // Should probably log.debug() this?
        cpe.printStackTrace();
    }
    if (c != null) {
        Iterator it = c.iterator();
        while (it.hasNext()) {
            List list = (List) it.next();
            int type = ((Integer) list.get(0)).intValue();
            // If type is 2, then we've got a dNSName
            if (type == 2) {
                String s = (String) list.get(1);
                subjectAltList.add(s);
            }
        }
    }
    if (!subjectAltList.isEmpty()) {
        String[] subjectAlts = new String[subjectAltList.size()];
        subjectAltList.toArray(subjectAlts);
        return subjectAlts;
    } else {
        return null;
    }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:45,代码来源:SSLHostnameVerifier.java

示例9: hostNameMessage

import java.security.cert.CertificateParsingException; //导入方法依赖的package包/类
private String hostNameMessage(X509Certificate cert, String hostname) {
    StringBuffer si = new StringBuffer();

    si.append(master.getString(R.string.mtm_hostname_mismatch, hostname));
    si.append("\n\n");
    try {
        Collection<List<?>> sans = cert.getSubjectAlternativeNames();
        if (sans == null) {
            si.append(cert.getSubjectDN());
            si.append("\n");
        } else for (List<?> altName : sans) {
            Object name = altName.get(1);
            if (name instanceof String) {
                si.append("[");
                si.append((Integer) altName.get(0));
                si.append("] ");
                si.append(name);
                si.append("\n");
            }
        }
    } catch (CertificateParsingException e) {
        e.printStackTrace();
        si.append("<Parsing error: ");
        si.append(e.getLocalizedMessage());
        si.append(">\n");
    }
    si.append("\n");
    si.append(master.getString(R.string.mtm_connect_anyway));
    si.append("\n\n");
    si.append(master.getString(R.string.mtm_cert_details));
    certDetails(si, cert);
    return si.toString();
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:34,代码来源:MemorizingTrustManager.java

示例10: getSubjectAlternativeNames

import java.security.cert.CertificateParsingException; //导入方法依赖的package包/类
/**
 * Returns the JID representation of an XMPP entity contained as a SubjectAltName extension
 * in the certificate. If none was found then return <tt>null</tt>.
 *
 * @param certificate the certificate presented by the remote entity.
 * @return the JID representation of an XMPP entity contained as a SubjectAltName extension
 *         in the certificate. If none was found then return <tt>null</tt>.
 */
private static List<String> getSubjectAlternativeNames(X509Certificate certificate) {
    List<String> identities = new ArrayList<String>();
    try {
        Collection<List<?>> altNames = certificate.getSubjectAlternativeNames();
        // Check that the certificate includes the SubjectAltName extension
        if (altNames == null) {
            return Collections.emptyList();
        }
        // Use the type OtherName to search for the certified server name
        /*for (List item : altNames) {
            Integer type = (Integer) item.get(0);
            if (type == 0) {
                // Type OtherName found so return the associated value
                try {
                    // Value is encoded using ASN.1 so decode it to get the server's identity
                    ASN1InputStream decoder = new ASN1InputStream((byte[]) item.toArray()[1]);
                    DEREncodable encoded = decoder.readObject();
                    encoded = ((DERSequence) encoded).getObjectAt(1);
                    encoded = ((DERTaggedObject) encoded).getObject();
                    encoded = ((DERTaggedObject) encoded).getObject();
                    String identity = ((DERUTF8String) encoded).getString();
                    // Add the decoded server name to the list of identities
                    identities.add(identity);
                }
                catch (UnsupportedEncodingException e) {
                    // Ignore
                }
                catch (IOException e) {
                    // Ignore
                }
                catch (Exception e) {
                    e.printStackTrace();
                }
            }
            // Other types are not good for XMPP so ignore them
            System.out.println("SubjectAltName of invalid type found: " + certificate);
        }*/
    }
    catch (CertificateParsingException e) {
        e.printStackTrace();
    }
    return identities;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:52,代码来源:ServerTrustManager.java

示例11: verifySSLHostname

import java.security.cert.CertificateParsingException; //导入方法依赖的package包/类
protected void verifySSLHostname(final SSLSocket sslSocket) throws IOException {
    if (!this.isSSLTrustALL()) {
        final SSLSession sslSession = sslSocket.getSession();
        if (sslSession != null && sslSession.getPeerCertificates().length > 0) {
            final Certificate certificate = sslSession.getPeerCertificates()[0];
            if (certificate instanceof X509Certificate) {
                final String hostname = this.getURL().getHost().toLowerCase(Locale.ENGLISH);
                final ArrayList<String> subjects = new ArrayList<String>();
                final X509Certificate x509 = (X509Certificate) certificate;
                subjects.add(new Regex(x509.getSubjectX500Principal().getName(), "CN=(.*?)(,| |$)").getMatch(0));
                try {
                    final Collection<List<?>> subjectAlternativeNames = x509.getSubjectAlternativeNames();
                    if (subjectAlternativeNames != null) {
                        for (final List<?> subjectAlternativeName : subjectAlternativeNames) {
                            final Integer generalNameType = (Integer) subjectAlternativeName.get(0);
                            switch (generalNameType) {
                            case 1:// rfc822Name
                            case 2:// dNSName
                                subjects.add(subjectAlternativeName.get(1).toString());
                                break;
                            }
                        }
                    }
                } catch (CertificateParsingException e) {
                    e.printStackTrace();
                }
                for (String subject : subjects) {
                    if (subject != null) {
                        subject = subject.toLowerCase(Locale.ENGLISH);
                        if (StringUtils.equals(subject, hostname)) {
                            return;
                        } else if (subject.startsWith("*.") && hostname.length() > subject.length() - 1 && hostname.endsWith(subject.substring(1)) && hostname.substring(0, hostname.length() - subject.length() + 1).indexOf('.') < 0) {
                            /**
                             * http://en.wikipedia.org/wiki/ Wildcard_certificate
                             */
                            return;
                        }
                    }
                }
                throw new SSLHandshakeException("HTTPS hostname wrong:  hostname is <" + hostname + ">");
            }
        }
    }
}
 
开发者ID:friedlwo,项目名称:AppWoksUtils,代码行数:45,代码来源:HTTPConnectionImpl.java


注:本文中的java.security.cert.CertificateParsingException.printStackTrace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。