OpenSSL> rsa -in uat.key.pem -out uat.key
Enter pass phrase for uat.key.pem:
writing RSA key
OpenSSL> pkcs12 -export -out keystore.pkcs12 -in uat_tls_rp.pem -inkey uat.key
Loading 'screen' into random state - done
Enter Export Password:
Verifying - Enter Export Password:
OpenSSL> exit
From P12 to JKS using Jetty :
C:\CFC>java -cp C:\openssl-0.9.8h-1-bin\bin\jetty-6.1.1.jar org.mortbay.jetty.security.PKCS12Import gtbtest.pkcs12 Test_keystore.jks
Enter input keystore passphrase: global12
Enter output keystore passphrase: global12
Alias 0: 1
Adding key for alias 1
This blog is dedicated to share my experience during my development as a purpose of notes and explorer various web / enterprise technologies like JAVA , JEE , Spring ,hybris, Portal , Jquery , RAI , JMS, Weblogic , SSL , Security, CS, MAC< Linux, Windows, Search, IOT, Arduino, Machine Learning, Tips, Angular, Node JS, React, Mac, Windows, Stack, Exception, Error etc. with examples.
Search This Blog
Showing posts with label SSL. Show all posts
Showing posts with label SSL. Show all posts
Tuesday, July 27, 2010
Sunday, June 6, 2010
java.lang.ClassCastException: weblogic.net.http.SOAPHttpsURLConnection - Weblogic
While making a HTTP(s) connection to external resource from weblogic server following exception comes because underline API uses weblogic implemntation ..
Caught Exception creating connection: java.lang.ClassCastException: weblogic.net.http.SOAPHttpsURLConnection
to avoid this problem ..
set following flag in the JVM args ..
-DUseSunHttpHandler=true
It will prefer to use sun implementation..
Caught Exception creating connection: java.lang.ClassCastException: weblogic.net.http.SOAPHttpsURLConnection
to avoid this problem ..
set following flag in the JVM args ..
-DUseSunHttpHandler=true
It will prefer to use sun implementation..
Wednesday, February 10, 2010
How to read cert from trust store (jks) and use for TLS check with HttpsURLConnection
Following code can help to create SSLSocketfactory for trusted cert by reading custom JKS (If you don't want to put cert in default trust store(cacrets) or don't want to set java system property).
This piece of code will be specific to your application and will not affect other applications if running in same JVM ...
private static String trustStorePasswd = "pass123";
private static String keyfactoryAlgorithm = "SunX509";
private static String sslContextProtocol = "SSL";
SSLContext sslCtx = SSLContext.getInstance(sslContextProtocol);
String sslTrustStore = "./setup/mytrust.jks"; // trust store file
// Create TrustManager
KeyStore trustKs = KeyStore.getInstance("JKS");
trustKs.load(new FileInputStream(sslTrustStore),
trustStorePasswd.toCharArray());
trustKs.load(is,
trustStorePasswd.toCharArray());
TrustManagerFactory tmf = TrustManagerFactory
.getInstance(keyfactoryAlgorithm);
tmf.init(trustKs);
sslCtx.init(null ,tmf.getTrustManagers(), null);
SSLSocketFactory socketFactory = sslCtx.getSocketFactory();
Now next step is to set socket factory into HttpsURLconnection :
HttpsURLconnection httpsconnections;
URL url = new URL("https://mysite.com:3434");
httpsconnections = (HttpsURLConnection) url.openConnection();
httpsconnections.setSSLSocketFactory(socketFactory);
now ur java code is ready to open connection to site and to use .. :)
cheers
This piece of code will be specific to your application and will not affect other applications if running in same JVM ...
private static String trustStorePasswd = "pass123";
private static String keyfactoryAlgorithm = "SunX509";
private static String sslContextProtocol = "SSL";
SSLContext sslCtx = SSLContext.getInstance(sslContextProtocol);
String sslTrustStore = "./setup/mytrust.jks"; // trust store file
// Create TrustManager
KeyStore trustKs = KeyStore.getInstance("JKS");
trustKs.load(new FileInputStream(sslTrustStore),
trustStorePasswd.toCharArray());
trustKs.load(is,
trustStorePasswd.toCharArray());
TrustManagerFactory tmf = TrustManagerFactory
.getInstance(keyfactoryAlgorithm);
tmf.init(trustKs);
sslCtx.init(null ,tmf.getTrustManagers(), null);
SSLSocketFactory socketFactory = sslCtx.getSocketFactory();
Now next step is to set socket factory into HttpsURLconnection :
HttpsURLconnection httpsconnections;
URL url = new URL("https://mysite.com:3434");
httpsconnections = (HttpsURLConnection) url.openConnection();
httpsconnections.setSSLSocketFactory(socketFactory);
now ur java code is ready to open connection to site and to use .. :)
cheers
Tuesday, February 9, 2010
Code to Disabling Certificate Validation in an HTTPS Connection HTTPSURLConnection
By default, accessing an HTTPS URL using the URL class results in an exception if the server's certificate chain cannot be validated has not previously been installed in the truststore. If you want to disable the validation of certificates for testing purposes, you need to override the default trust manager with one that trusts all certificates.
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
}
}
};
// Install the all-trusting trust manager
try {
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
} catch (Exception e) {
}
// Now you can access an https URL without having the certificate in the truststore
try {
URL url = new URL("https://hostname/index.html");
} catch (MalformedURLException e) {
}
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
}
}
};
// Install the all-trusting trust manager
try {
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
} catch (Exception e) {
}
// Now you can access an https URL without having the certificate in the truststore
try {
URL url = new URL("https://hostname/index.html");
} catch (MalformedURLException e) {
}
Sunday, January 31, 2010
command to verify pem file from existing utility of weblogic
Following way we can verify cert chain in pem file using weblogic utility :
java -cp C:/weblogic8Lib/weblogic.jar utils.ValidateCertChain -pem mysecure.pem
Certificate chain is invalid
java -cp C:/weblogic8Lib/weblogic.jar utils.ValidateCertChain -pem mysecure.pem
Certificate chain is invalid
Tuesday, January 12, 2010
Default key store information for weblogic
If you are connecting to the server you need to know where the key stores live, so here is a table with all the default values in:
Sample import command :
C:\bea\wlserver_10.0\server\lib>keytool -import -alias local -file C:\SMS\cert\
local-ssl.cer -keystore DemoTrust.jks -storepass DemoTrustKeyStorePassPhrase
| Property | Value |
| Trust store location | %ORACLE_HOME%/weblogic/wlserver_10.3/ server/lib/DemoTrust.jks |
| Trust store password | DemoTrustKeyStorePassPhrase |
| Key store location | %ORACLE_HOME%/weblogic/wlserver_10.3/ server/lib/DemoIdentity.jks |
| Key store password | DemoIdentityKeyStorePassPhrase |
| Private key password | DemoIdentityPassPhrase |
Sample import command :
C:\bea\wlserver_10.0\server\lib>keytool -import -alias local -file C:\SMS\cert\
local-ssl.cer -keystore DemoTrust.jks -storepass DemoTrustKeyStorePassPhrase
Wednesday, September 9, 2009
SSL debug JVM arguments for weblogic
set these arguments in setDomainEnv.cmd file in the variable JAVA_PROPETIES =
-Dssl.debug=true
-Dweblogic.webservice.client.verbose=true
-Dweblogic.security.SSL.verbose=true
-Dweblogic.StdoutDebugEnabled=true
-Dweblogic.webservice.binding.verbose=true
It will give you more help to debug SSL errors during webservice call on secure connections
And if using javax.net package for SSL then following args is help full :
javax.net.debug=all
-Dssl.debug=true
-Dweblogic.webservice.client.verbose=true
-Dweblogic.security.SSL.verbose=true
-Dweblogic.StdoutDebugEnabled=true
-Dweblogic.webservice.binding.verbose=true
It will give you more help to debug SSL errors during webservice call on secure connections
And if using javax.net package for SSL then following args is help full :
javax.net.debug=all
Subscribe to:
Posts (Atom)
Popular Posts
-
Communication of nodes in SAP commerce(Hybris) environment was failing in cluster with following error: INFO | jvm 1 | main | 2020/0...
-
I had encountered issue while added theme-chalk into scss. It was not loading on the browser. Following line added in scss file and it...
-
If each of your microservices is containerized using Docker, you can use Docker Compose to define and run all of your services in one go. T...
-
< c:if test="${param.name != null}">< /c:if> The above tag is to check whether parameter name is null or not. If i...