@SuppressWarnings("static-method") @Test public void testCertGeneration() throws Exception { final CertPack cp = CertUtil.getCertPackForLocalhostSsl("AutoFirma", "654321"); System.out.println(AOUtil.getCN((X509Certificate) cp.getCaCertificate())); System.out.println(AOUtil.getCN((X509Certificate) cp.getSslCertificate())); System.out.println(); System.out.println(); System.out.println(AOUtil.hexify(cp.getPkcs12(), true)); try ( final OutputStream fos = new FileOutputStream(File.createTempFile("SSLCERT_", ".cer")) ) { fos.write(cp.getSslCertificate().getEncoded()); } try ( final OutputStream fos = new FileOutputStream(File.createTempFile("CACERT_", ".cer")) ) { fos.write(cp.getCaCertificate().getEncoded()); } }
static CertPack getCertPackForLocalhostSsl(final String sslCertificateAlias, final String storePassword) throws NoSuchAlgorithmException, CertificateException, IOException { return getCertPackForHostSsl( sslCertificateAlias, storePassword, DEFAULT_LOCALHOST_IP, new String[] { DEFAULT_LOCALHOST_HOSTNAME }, ROOT_CERTIFICATE_PRINCIPAL ); }
CertUtil { static CertPack getCertPackForLocalhostSsl(final String sslCertificateAlias, final String storePassword) throws NoSuchAlgorithmException, CertificateException, IOException { return getCertPackForHostSsl( sslCertificateAlias, storePassword, DEFAULT_LOCALHOST_IP, new String[] { DEFAULT_LOCALHOST_HOSTNAME }, ROOT_CERTIFICATE_PRINCIPAL ); } }
CertUtil { static CertPack getCertPackForLocalhostSsl(final String sslCertificateAlias, final String storePassword) throws NoSuchAlgorithmException, CertificateException, IOException { return getCertPackForHostSsl( sslCertificateAlias, storePassword, DEFAULT_LOCALHOST_IP, new String[] { DEFAULT_LOCALHOST_HOSTNAME }, ROOT_CERTIFICATE_PRINCIPAL ); }  }
CertUtil { static CertPack getCertPackForLocalhostSsl(final String sslCertificateAlias, final String storePassword) throws NoSuchAlgorithmException, CertificateException, IOException { return getCertPackForHostSsl( sslCertificateAlias, storePassword, DEFAULT_LOCALHOST_IP, new String[] { DEFAULT_LOCALHOST_HOSTNAME }, ROOT_CERTIFICATE_PRINCIPAL ); }   }
CertUtil { static CertPack getCertPackForLocalhostSsl(final String sslCertificateAlias, final String storePassword) throws NoSuchAlgorithmException, CertificateException, IOException { return getCertPackForHostSsl( sslCertificateAlias, storePassword, DEFAULT_LOCALHOST_IP, new String[] { DEFAULT_LOCALHOST_HOSTNAME }, ROOT_CERTIFICATE_PRINCIPAL ); }    }