code: public X509Certificate generateSelfSignedCertificate(String subjectDN, KeyPair pair, int days, String algorithm) throws CertificateException
      {
          return generateCertificate(subjectDN, null, pair, null, days, algorithm);
      }
docs: Create a self-signed X.509 Certificate
  
  @param subjectDN the X.509 Distinguished Name, eg "CN=Test, L=London, C=GB"
  @param pair the KeyPair
  @param days how many days from now the Certificate is valid for
  @param algorithm the signing algorithm, e.g. "SHA1withRSA"
  @return
  @throws java.security.cert.CertificateException