EldoS | Feel safer!

Software components for data protection, secure storage and transfer

https cert sign

Posted: 11/25/2015 10:50:06
by Javier Karas (Standard support level)
Joined: 08/24/2015
Posts: 7

Sorry but this is maybe already answered but I don't know what to look for, I've to reproduce a java code in delphi, the code uses a certificate to sign (?) a https request, there is a way to reproduce this with secure black box?

         System.out.println("testing connection to wsdl and import certificates");

         KeyStore ks = KeyStore.getInstance("PKCS12");
         System.out.println("load p12 file" + location);
         ks.load(new FileInputStream(location), CERT_PASSWORD.toCharArray());

         System.out.println("get certificate");
         java.security.cert.Certificate cert = ks.getCertificate(CERT_NAME);

         System.out.println("get keymanagerfactory" + cert.toString());
         KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
         kmf.init(ks, CERT_PASSWORD.toCharArray());
         KeyManager[] kms = kmf.getKeyManagers();

         KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());

         trustStore.load(new FileInputStream(System.getProperty("java.home") + "\\lib\\security\\cacerts"),

         TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
         TrustManager[] tms = tmf.getTrustManagers();

         SSLContext sslContext = SSLContext.getInstance("TLS");
         sslContext.init(kms, tms, new SecureRandom());
         System.out.println("finish ssl import");

         String endPoint = END_POINT;
         URL wsdlLocation = new URL(endPoint + "?wsdl");

         System.out.println("test connection");
         HttpsURLConnection urlConn = (HttpsURLConnection) wsdlLocation.openConnection();

         System.out.println("finish test connection");

Complete code is attached
Posted: 11/25/2015 10:53:32
by Eugene Mayevski (Team)

Here you deal with client-side authentication in TLS.

Please see the sample of doing this in SecureBlackbox\Samples\Delphi\SSLBlackbox\Client\SimpleSSL directory.

The sample uses OnCertificateNeededEx event. You can use ClientCertStorage property instead (please don't use them together, though). Or you can start with the approach shown in the sample and once everything work, switch to ClientCertStorage .

Sincerely yours
Eugene Mayevski
Posted: 11/25/2015 11:10:12
by Javier Karas (Standard support level)
Joined: 08/24/2015
Posts: 7

Thanks, I will check that



Topic viewed 1796 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!