CertificateHandler
public class CertificateHandler
extends java.lang.Object
A utility class for handling SSL/TLS certificate operations such as conversion between PEM and X509Certificate, keystore generation, thumbprint calculation, and SSL context creation.
Constructor:
public CertificateHandler()
Creates an instance of the CertificateHandler. This class uses static methods, so instantiation is unnecessary.
Methods:
X509Certificate convertToX509Certificate(String pem) |
Parses a PEM-encoded certificate string and returns an X509Certificate object. Throws: CertificateException, IOException |
KeyStore getKeyStore(String certificate, String certificateChain, String privateKey) |
Generates a KeyStore from provided certificate, certificate chain, and private key strings. Throws: Exception (for general parsing or conversion failures) |
String convertFromX509Certificate(X509Certificate cert) |
Converts an X509Certificate object back into a PEM-encoded string. Throws: CertificateException, IOException |
String getThumbprint(X509Certificate cert) |
Computes the SHA-1 thumbprint (hash) of the provided certificate. Throws: CertificateEncodingException, NoSuchAlgorithmException |
SSLContext createSslContext(KeyStore ks, KeyStore ts) |
Creates and returns an SSLContext initialized with the provided key and trust stores. Throws: IOException (typically due to misconfiguration or invalid stores) |
Methods inherited from class java.lang.Object |
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Start innovating with Mobius
What's next? Let's talk!