public class SSLTools extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static char[] |
hexArray |
| Constructor and Description |
|---|
SSLTools() |
| Modifier and Type | Method and Description |
|---|---|
static String |
cleanRSAPrivateKeyPem(String privateKeyText) |
static KeyPair |
generateKeyPair(int keysize) |
static String |
getCertificateModulusSHA1(X509Certificate cert)
Gets the modulus byte array from the X.509 certificate and calculates the
SHA-1 digest and return a hex string representation of the SHA-1.
|
static String |
getDkimDnsTxt(String privateKeyText) |
static org.bouncycastle.openssl.PasswordFinder |
getPasswordFinder(char[] password)
returns an instance of PasswordFinder containing the given password
|
static org.bouncycastle.openssl.PasswordFinder |
getPasswordFinder(String password)
returns an instance of PasswordFinder containing the given password
|
static String |
getPrivateKeyModulusSHA1(RSAPrivateKey rsaPrivateKey)
Gets the modulus byte array from the RSA private key and calculates the
SHA-1 digest and return a hex string representation of the SHA-1.
|
static PublicKey |
getPublicKeyFromPrivateKey(byte[] privateKeyBytes,
String password) |
static boolean |
isCertificateValid(String certificateText,
String privateKeyText)
Checks whether the X.509 certificates public key was generated from the
given private key
|
static boolean |
isCertificateValid(String certificateText,
String privateKeyText,
char[] privateKeyPassword)
Checks whether the X.509 certificates public key was generated from the
given RSA private key
|
static boolean |
isCertificateValid(X509Certificate cert,
RSAPrivateKey privateKey)
Checks whether the X.509 certificates public key was generated from the
given RSA private key
|
static Certificate |
parseCertificate(byte[] certificateBytes) |
static Certificate |
parseCertificate(String certificateText) |
static KeyPair |
parseKeyPair(byte[] privateKeyBytes,
String password) |
static KeyPair |
parseKeyPair(String privateKeyText) |
static KeyPair |
parseKeyPair(String privateKeyText,
String password) |
static PrivateKey |
parsePrivateKey(byte[] privateKeyBytes) |
static PrivateKey |
parsePrivateKey(byte[] privateKeyBytes,
char[] password) |
static PrivateKey |
parsePrivateKey(String privateKeyText) |
static PrivateKey |
parsePrivateKey(String privateKeyText,
char[] password) |
static PublicKey |
parsePublicKey(String publicKeyPEM) |
static RSAPrivateKey |
parseRSAPrivateKey(String privateKeyText) |
static RSAPrivateKey |
parseRSAPrivateKey(String privateKeyText,
char[] password) |
static X509Certificate |
parseX509Certificate(byte[] certificateBytes) |
static X509Certificate |
parseX509Certificate(String certificateText) |
static Object |
pemReader(String pem) |
static String |
pemWriter(Object o) |
static String |
toHexString(byte[] bytes)
returns a hex representation of the byte array
|
public static Certificate parseCertificate(String certificateText) throws CertificateException
CertificateExceptionpublic static Certificate parseCertificate(byte[] certificateBytes) throws CertificateException
certificateBytes - CertificateExceptionpublic static X509Certificate parseX509Certificate(String certificateText) throws CertificateException
certificateText - CertificateExceptionpublic static X509Certificate parseX509Certificate(byte[] certificateBytes) throws CertificateException
certificateBytes - CertificateExceptionpublic static PrivateKey parsePrivateKey(String privateKeyText) throws GeneralSecurityException, IOException
privateKeyText - GeneralSecurityExceptionIOExceptionpublic static PrivateKey parsePrivateKey(String privateKeyText, char[] password) throws GeneralSecurityException, IOException
privateKeyText - password - GeneralSecurityExceptionIOExceptionpublic static PrivateKey parsePrivateKey(byte[] privateKeyBytes) throws GeneralSecurityException, IOException
privateKeyBytes - GeneralSecurityExceptionIOExceptionpublic static PrivateKey parsePrivateKey(byte[] privateKeyBytes, char[] password) throws GeneralSecurityException, IOException
privateKeyBytes - password - GeneralSecurityExceptionIOExceptionpublic static KeyPair parseKeyPair(String privateKeyText) throws GeneralSecurityException, IOException
privateKeyText - GeneralSecurityExceptionIOExceptionpublic static KeyPair parseKeyPair(String privateKeyText, String password) throws GeneralSecurityException, IOException
privateKeyText - password - GeneralSecurityExceptionIOExceptionpublic static KeyPair parseKeyPair(byte[] privateKeyBytes, String password) throws GeneralSecurityException, IOException
privateKeyBytes - password - GeneralSecurityExceptionIOExceptionpublic static PublicKey getPublicKeyFromPrivateKey(byte[] privateKeyBytes, String password) throws IOException, GeneralSecurityException
privateKeyBytes - password - IOExceptionGeneralSecurityExceptionpublic static RSAPrivateKey parseRSAPrivateKey(String privateKeyText, char[] password) throws GeneralSecurityException, IOException
privateKeyText - password - GeneralSecurityExceptionIOExceptionpublic static RSAPrivateKey parseRSAPrivateKey(String privateKeyText) throws GeneralSecurityException, IOException
privateKeyText - GeneralSecurityExceptionIOExceptionpublic static PublicKey parsePublicKey(String publicKeyPEM) throws IOException
IOExceptionpublic static String getCertificateModulusSHA1(X509Certificate cert) throws NoSuchAlgorithmException
cert - NoSuchAlgorithmExceptionpublic static String getPrivateKeyModulusSHA1(RSAPrivateKey rsaPrivateKey)
rsaPrivateKey - public static boolean isCertificateValid(String certificateText, String privateKeyText) throws GeneralSecurityException, IOException
certificateText - privateKeyText - GeneralSecurityExceptionIOExceptionpublic static boolean isCertificateValid(String certificateText, String privateKeyText, char[] privateKeyPassword) throws GeneralSecurityException, IOException
certificateText - privateKeyText - privateKeyPassword - GeneralSecurityExceptionIOExceptionpublic static boolean isCertificateValid(X509Certificate cert, RSAPrivateKey privateKey) throws NoSuchAlgorithmException
cert - privateKey - NoSuchAlgorithmExceptionpublic static org.bouncycastle.openssl.PasswordFinder getPasswordFinder(String password)
password - public static org.bouncycastle.openssl.PasswordFinder getPasswordFinder(char[] password)
password - public static String getDkimDnsTxt(String privateKeyText) throws IOException, GeneralSecurityException
privateKeyText - IOExceptionGeneralSecurityExceptionpublic static KeyPair generateKeyPair(int keysize) throws NoSuchAlgorithmException
keysize - NoSuchAlgorithmExceptionpublic static String cleanRSAPrivateKeyPem(String privateKeyText)
privateKeyText - public static String toHexString(byte[] bytes)
bytes - public static String pemWriter(Object o) throws IOException
o - IOExceptionpublic static Object pemReader(String pem) throws IOException
pem - IOExceptionCopyright © 2021 McEvoy Software Ltd. All rights reserved.