EldoS | Feel safer!

Software components for data protection, secure storage and transfer

https cert sign

Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.
#35105
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?

Code
         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"),
               "changeit".toCharArray());

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

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

         HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
         String endPoint = END_POINT;
         URL wsdlLocation = new URL(endPoint + "?wsdl");

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

         urlConn.connect();
         urlConn.disconnect();
         System.out.println("finish test connection");


Complete code is attached
#35106
Posted: 11/25/2015 10:53:32
by Eugene Mayevski (EldoS Corp.)

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
#35108
Posted: 11/25/2015 11:10:12
by Javier Karas (Standard support level)
Joined: 08/24/2015
Posts: 7

Thanks, I will check that

Reply

Statistics

Topic viewed 1422 times

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




|

Back to top

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

Got it!