public static synchronized X509Certificate createX509V3Certificate(KeyPair kp, int days, String issuerCommonName,
                                                                        String subjectCommonName, String domain,
                                                                        String signAlgoritm, Set<String> sanDnsNames)
            throws GeneralSecurityException, IOException {

        // subjectDN
        X500NameBuilder subjectBuilder = new X500NameBuilder();
        subjectBuilder.addRDN(BCStyle.CN, subjectCommonName);

        // issuerDN
        X500NameBuilder issuerBuilder = new X500NameBuilder();
        issuerBuilder.addRDN(BCStyle.CN, issuerCommonName);

        return createX509V3Certificate(kp, days, issuerBuilder, subjectBuilder, domain, signAlgoritm, sanDnsNames);
    }
Creates an X509 version3 certificate.

@param kp           KeyPair that keeps the public and private keys for the new certificate.
@param days       time to live
@param issuerCommonName     Issuer CN string
@param subjectCommonName    Subject CN string
@param domain       Domain of the server.
@param signAlgoritm Signature algorithm. This can be either a name or an OID.
@return X509 V3 Certificate
@throws GeneralSecurityException if there was a problem creating the certificate
@throws IOException if there was a problem creating the certificate
xmppserver/src/main/java/org/jivesoftware/util/CertificateManager.java