Skip to content

Instantly share code, notes, and snippets.

View saumilsdk's full-sized avatar

Saumil Kapadia saumilsdk

  • Harman International
  • Bangalore
View GitHub Profile
@saumilsdk
saumilsdk / SslUtil.java
Last active October 26, 2023 09:53 — forked from rohanag12/SslUtil.java
Create an SslSocketFactory using PEM encrypted certificate files
/**
* 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