CertificateUtil

public abstract class CertificateUtil

Created: Sep 22, 2010 3:09:01 PM

Author:Artur Hefczyc

Fields

ID_ON_XMPPADDR

protected static final byte[] ID_ON_XMPPADDR

Methods

createKeyPair

public static KeyPair createKeyPair(int size, String password)

createSelfSignedCertificate

public static X509Certificate createSelfSignedCertificate(String email, String domain, String organizationUnit, String organization, String city, String state, String country, KeyPair keyPair)

createSelfSignedCertificate

public static CertificateEntry createSelfSignedCertificate(String email, String domain, String organizationUnit, String organization, String city, String state, String country, KeyPairSupplier keyPairSupplier)

exportToPemFormat

public static String exportToPemFormat(CertificateEntry entry)

extractCN

protected static String extractCN(X500Principal principal)

extractXmppAddrs

public static List<String> extractXmppAddrs(X509Certificate x509Certificate)

getCertAltCName

public static List<String> getCertAltCName(X509Certificate cert)

getCertCName

public static String getCertCName(X509Certificate cert)

getCertificateBasicInfo

public static String getCertificateBasicInfo(Certificate cert)

getCertificateBasicInfo

public static StringBuilder getCertificateBasicInfo(StringBuilder sb, Certificate cert)

getCertificateFingerprint

public static String getCertificateFingerprint(Certificate cert)

getCertificateSerialNumber

public static Optional<BigInteger> getCertificateSerialNumber(Certificate cert)

isExpired

public static boolean isExpired(X509Certificate cert)

isSelfSigned

public static boolean isSelfSigned(X509Certificate cert)

loadCertificate

public static CertificateEntry loadCertificate(File file)

loadCertificate

public static CertificateEntry loadCertificate(byte[] bytes)

Loads a certificate from a DER byte buffer.

loadCertificate

public static CertificateEntry loadCertificate(String file)

loadPrivateKeyFromDER

public static PrivateKey loadPrivateKeyFromDER(File file)

main

public static void main(String[] args)

match

public static boolean match(String hostname, String altName)

Checks if hostname matches name or wildcard

Returns:true if there is a match

parseCertificate

public static CertificateEntry parseCertificate(Reader data)

sort

public static Certificate[] sort(Certificate[] chain)

sort

public static List<Certificate> sort(List<Certificate> certs)

storeCertificate

public static void storeCertificate(String file, CertificateEntry entry)

validateCertificate

public static CertCheckResult validateCertificate(Certificate[] chain, KeyStore trustKeystore, boolean revocationEnabled)

verifyCertificateForDomain

public static boolean verifyCertificateForDomain(X509Certificate cert, String hostname)

Method used to verify if certificate if valid for particular domain (if domain matches CN or ALT of certificate)

Returns:true if certificate is valid

verifyCertificateForHostname

protected static boolean verifyCertificateForHostname(String hostname, X509Certificate x509Certificate)

verifyCertificateForIp

protected static boolean verifyCertificateForIp(String ipAddr, X509Certificate x509Certificate)