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


Java X509TrustManager.getAcceptedIssuers方法代码示例

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


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

示例1: create

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
private void create(Path path)
    throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException,
    KeyManagementException {
  TrustManager[] trustManagers;
  KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
  keyStore.load(null, null);

  installCertificates(path, keyStore);

  String defaultAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
  TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(defaultAlgorithm);
  trustManagerFactory.init(keyStore);
  trustManagers = trustManagerFactory.getTrustManagers();
  sslContext = SSLContext.getInstance("TLS");
  sslContext.init(null, trustManagers, null);
  trustManager = (X509TrustManager) trustManagers[0];
  X509Certificate[] acceptedIssuers = trustManager.getAcceptedIssuers();
  for (X509Certificate acceptedIssuer : acceptedIssuers) {
    logger.info("installed cert details: subject={} issuer={}",
        acceptedIssuer.getSubjectX500Principal(), acceptedIssuer.getIssuerX500Principal());
  }
}
 
开发者ID:dehora,项目名称:outland,代码行数:23,代码来源:CertificateLoader.java

示例2: X509TrustManagerWrapper

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
public X509TrustManagerWrapper(X509TrustManager tm, boolean verifyServerCertificate) throws CertificateException {
    this.origTm = tm;
    this.verifyServerCert = verifyServerCertificate;

    if (verifyServerCertificate) {
        try {
            Set<TrustAnchor> anch = new HashSet<TrustAnchor>();
            for (X509Certificate cert : tm.getAcceptedIssuers()) {
                anch.add(new TrustAnchor(cert, null));
            }
            this.validatorParams = new PKIXParameters(anch);
            this.validatorParams.setRevocationEnabled(false);
            this.validator = CertPathValidator.getInstance("PKIX");
            this.certFactory = CertificateFactory.getInstance("X.509");
        } catch (Exception e) {
            throw new CertificateException(e);
        }
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:20,代码来源:ExportControlled.java

示例3: dumpTrustedCerts

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
public void dumpTrustedCerts() {
	try {
		TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory
				.getDefaultAlgorithm());
		tmf.init((KeyStore) null);
		X509TrustManager xtm = (X509TrustManager) tmf.getTrustManagers()[0];
		StringBuffer buff = new StringBuffer();
		for (X509Certificate cert : xtm.getAcceptedIssuers()) {
			String certStr = "S:" + cert.getSubjectDN().getName() + "\nI:"
					+ cert.getIssuerDN().getName();
			Log.d(TAG, certStr);
			buff.append(certStr + "\n\n");
		}
	} catch (GeneralSecurityException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:CactusSoft,项目名称:zabbkit-android,代码行数:18,代码来源:SSLManager.java

示例4: KeyStoresTrustManager

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
public KeyStoresTrustManager(KeyStore... keyStores) throws NoSuchAlgorithmException, KeyStoreException {
    super();

    for (KeyStore keystore : keyStores) {
        TrustManagerFactory factory = TrustManagerFactory.getInstance("JKS");
        factory.init(keystore);
        TrustManager[] tms = factory.getTrustManagers();
        if (tms.length == 0) {
            throw new NoSuchAlgorithmException("Unable to load keystore");
        }
        trustManagers.add((X509TrustManager) tms[0]);
    }

    //Build accepted issuers list
    Set<X509Certificate> issuers = new HashSet<X509Certificate>();
    for (X509TrustManager tm : trustManagers) {
        for (X509Certificate issuer : tm.getAcceptedIssuers()) {
            issuers.add(issuer);
        }
    }
    acceptedIssuers = issuers.toArray(new X509Certificate[issuers.size()]);
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:23,代码来源:KeyStoresTrustManager.java

示例5: getAcceptedIssuers

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
@Override
public X509Certificate[] getAcceptedIssuers() {
  X509Certificate[] issuers = EMPTY;
  X509TrustManager tm = trustManagerRef.get();
  if (tm != null) {
    issuers = tm.getAcceptedIssuers();
  }
  return issuers;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:10,代码来源:ReloadingX509TrustManager.java

示例6: createSome

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
@Test
public void createSome() throws IOException {
  CertificateLoader securitySupport =
      new CertificateLoader("classpath:certs");

  X509TrustManager x509TrustManager = securitySupport.trustManager();
  SSLContext sslContext = securitySupport.sslContext();
  assertNotNull(x509TrustManager);
  assertNotNull(sslContext);
  X509Certificate[] acceptedIssuers = x509TrustManager.getAcceptedIssuers();

  assertEquals(3, acceptedIssuers.length);

  String issuer1 = "CN=Let's Encrypt Authority X1, O=Let's Encrypt, C=US";
  String issuer2 = "CN=Let's Encrypt Authority X2, O=Let's Encrypt, C=US";
  String issuer3 = "CN=Let's Encrypt Authority X3, O=Let's Encrypt, C=US";
  Set<String> seen = Sets.newHashSet();
  for (X509Certificate acceptedIssuer : acceptedIssuers) {
    String name = acceptedIssuer.getSubjectDN().getName();
    System.out.println(name);
    if (issuer1.equals(name)) {
      seen.add(name);
    }

    if (issuer2.equals(name)) {
      seen.add(name);
    }

    if (issuer3.equals(name)) {
      seen.add(name);
    }
  }

  assertEquals(3, seen.size());
  assertTrue(seen.contains(issuer1));
  assertTrue(seen.contains(issuer2));
  assertTrue(seen.contains(issuer3));
}
 
开发者ID:dehora,项目名称:outland,代码行数:39,代码来源:CertificateLoaderTest.java

示例7: createNone

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
@Test
public void createNone() throws IOException {
  String fPath = "file://" + folder.newFolder().getAbsolutePath();
  CertificateLoader securitySupport = new CertificateLoader(fPath);
  X509TrustManager x509TrustManager = securitySupport.trustManager();
  SSLContext sslContext = securitySupport.sslContext();

  assertNotNull(x509TrustManager);
  assertNotNull(sslContext);

  X509Certificate[] acceptedIssuers = x509TrustManager.getAcceptedIssuers();
  assertEquals(0, acceptedIssuers.length);
}
 
开发者ID:dehora,项目名称:outland,代码行数:14,代码来源:CertificateLoaderTest.java

示例8: buildTrustRootIndex

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
public TrustRootIndex buildTrustRootIndex(X509TrustManager trustManager) {
  return new BasicTrustRootIndex(trustManager.getAcceptedIssuers());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:Platform.java

示例9: trustRootIndex

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
public TrustRootIndex trustRootIndex(X509TrustManager trustManager) {
    return new RealTrustRootIndex(trustManager.getAcceptedIssuers());
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:Platform.java


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