[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SV: [iaik-ssl] PEM fcertificate?



Title: SV: [iaik-ssl] PEM fcertificate?

  public RSVIAIKSocket(String host,int port,String clientCert,String key,String serverCert) throws Exception
  {
    IAIK.addAsProvider();
   
    SSLClientContext context = new SSLClientContext();
    context.setChainVerifier(null);
   
    X509Certificate chain[] = new X509Certificate[2];
   
    InputStream inStream = new FileInputStream(clientCert);
    chain[0] = new X509Certificate(inStream);
    inStream.close();

    inStream = new FileInputStream(serverCert);
    chain[1] = new X509Certificate(inStream);
    inStream.close();
   
    inStream = new FileInputStream(key);
    PrivateKey privateKey = new SSLeayPrivateKey(inStream).getPrivateKey();
    inStream.close();
   
    context.addClientCredentials(chain, privateKey);
   
    socket = new SSLSocket(host, port, context);
  }

where clientCert and serverCert are PEM-files.

/jonas