Skip to content

Instantly share code, notes, and snippets.

Avatar

Saumil Kapadia saumilsdk

  • Harman International
  • Bangalore
View GitHub Profile
@saumilsdk
saumilsdk / SslUtil.java
Last active Jul 28, 2021 — forked from rohanag12/SslUtil.java
Create an SslSocketFactory using PEM encrypted certificate files
View SslUtil.java
/**
* Utility class to read encrypted PEM files and generate a SSL Socket Factory based on the provided certificates.
* This utility also support an option to enable and disable server hostname verification.
*
* Note: Java use jks (Java KeyStore) format, but openssl usual use pem format. We can convert it by keytool (jdk build-in tool), or use
* BouncyCastle library to handle pem.
*
* The original code is by Sharon Asher (link below). I have modified it to use a newer version of the BouncyCastle Library (v1.68)
* Add below dependencies to work with this util.
* org.bouncycastle:bcpkix-jdk15on:1.68