Skip to content

Instantly share code, notes, and snippets.

@jeongho
Created February 23, 2017 04:17
Show Gist options
  • Save jeongho/66f17571d664119ca60193a49de1699d to your computer and use it in GitHub Desktop.
Save jeongho/66f17571d664119ca60193a49de1699d to your computer and use it in GitHub Desktop.
Java HTTPS to a server with a self-signed certificate Raw
http://www.artificialworlds.net/blog/2015/12/07/java-https-to-a-server-with-a-self-signed-certificate/
cat << EOF > Get.java
import java.net.URL;
public class Get
{
public static void main( String[] args ) throws Exception
{
try
{
new URL( args[0] ).openConnection().getInputStream();
System.out.println( "Succeeded." );
}
catch( javax.net.ssl.SSLHandshakeException e )
{
System.out.println( "SSL exception." );
}
}
}
EOF
javac Get.java
java Get https://google.com
Succeeded.
java \
Get https://c000-srv7.antarcticatec.com:8985/solr
SSL exception.
todo:
- create a truststore with importing certificates from all servers in a cluster
- distribute the truststore to all servers in the cluster
java \
-Djavax.net.ssl.trustStore=/opt/antarcticatec/security/jks/antarcticatec.truststore.jks \
-Djavax.net.ssl.trustStorePassword=nautilus \
Get https://c000-srv7.antarcticatec.com:8985/solr
Succeeded.
java \
-Djavax.net.ssl.trustStore=/opt/antarcticatec/security/jks/antarcticatec.truststore.jks \
-Djavax.net.ssl.trustStorePassword=nautilus \
-Djavax.net.debug=ssl:handshake \
Get https://c000-srv7.antarcticatec.com:8985/solr
Succeeded.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment