Class X509Support
java.lang.Object
zeroecho.sdk.util.X509Support
Utility class providing support for working with X.509 certificates, private
keys, and certification requests using PEM-encoded files and the Bouncy
Castle library.
This class includes static helper methods to:
- Load an X.509 certificate from a PEM file
- Load a PKCS#10 certification request (CSR) from a PEM file
- Print a
PrivateKeyin PEM format - Print a
Certificate, including its PEM-encoded form
All methods are static and the class cannot be instantiated.
Note: This class relies on the Bouncy Castle library and assumes the Bouncy Castle provider is correctly configured.
- Author:
- Leo Galambos
-
Method Summary
Modifier and TypeMethodDescriptionstatic CertificateloadCertificate(String path) Loads an X509Certificate from a PEM file.static CertificationRequestLoads a PKCS#10 Certification Request (CSR) from a PEM file.static voidprintCertificate(Certificate cert) Prints the certificate details to standard output, including its PEM encoded representation.static voidprintPrivateKey(PrivateKey privKey) Utility method to print aPrivateKeyin PEM format to standard output.
-
Method Details
-
loadCertificate
Loads an X509Certificate from a PEM file.- Parameters:
path- the file path to the certificate PEM file- Returns:
- the loaded
X509Certificateor null if invalid - Throws:
IOException- if an I/O error occurs reading the file
-
printPrivateKey
Utility method to print aPrivateKeyin PEM format to standard output.This method writes the private key using a
JcaPEMWriterand prints it to the console in PEM (Base64-encoded) format. If an error occurs during the writing process, it logs a warning.- Parameters:
privKey- thePrivateKeyto print
-
printCertificate
Prints the certificate details to standard output, including its PEM encoded representation.- Parameters:
cert- theCertificateto print
-
loadCSR
Loads a PKCS#10 Certification Request (CSR) from a PEM file.- Parameters:
path- the file path to the CSR PEM file- Returns:
- the loaded
CertificationRequestor null if invalid - Throws:
IOException- if an I/O error occurs reading the file
-