Created
June 6, 2016 09:21
-
-
Save kasimok/cb5833a8b754f74f0675d203d7ca16ab to your computer and use it in GitHub Desktop.
Certificate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Read PEM certificate into javax.security.x509Certificate. | |
* @param certText | |
* @return | |
*/ | |
private X509Certificate readPemCert(String certText) { | |
CertificateFactory certificateFactory = null; | |
try { | |
certificateFactory = CertificateFactory.getInstance("X.509"); | |
} catch (CertificateException e) { | |
e.printStackTrace(); | |
} | |
X509Certificate x509cert = null; | |
InputStream stream = new ByteArrayInputStream(certText.getBytes(StandardCharsets.UTF_8)); | |
try { | |
x509cert = (X509Certificate) certificateFactory.generateCertificate(stream); | |
return x509cert; | |
} catch (CertificateException e) { | |
e.printStackTrace(); | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment