Ejemplo n.º 1
0
  private SSLContext makeSSLContext(TLSParams p)
      throws NoSuchAlgorithmException, KeyManagementException {
    SSLContext ctx = SSLContext.getInstance("TLS");
    KeyManager[] kms = null;
    TrustManager[] tms = null;
    X509CRL crl = null;

    if (p.getKeyStore() != null) {
      kms = makeKeyStore(p.getKeyStore(), p.getPassphrase());
    }
    if (p.getTrustStore() != null) {
      tms = makeTrustStore(p.getTrustStore());
    }
    if (p.getCrl() != null) {
      crl = makeCRL(p.getCrl());
    }

    if ((tms != null) && (crl != null)) {
      tms[0] = new CompositeTrustManager((X509TrustManager) tms[0], crl);
    }

    ctx.init(kms, tms, null);
    return ctx;
  }