public X509Certificate getMappedCertificateForHostname ( String hostname ) throws CertificateParsingException , InvalidKeyException , CertificateExpiredException , CertificateNotYetValidException , SignatureException , CertificateException , NoSuchAlgorithmException , NoSuchProviderException , KeyStoreException , UnrecoverableKeyException { String subject = getSubjectForHostname ( hostname ) ; String thumbprint = _subjectMap . get ( subject ) ; if ( thumbprint == null ) { KeyPair kp = getRSAKeyPair ( ) ; X509Certificate newCert = CertificateCreator . generateStdSSLServerCertificate ( kp . getPublic ( ) , getSigningCert ( ) , getSigningPrivateKey ( ) , subject ) ; addCertAndPrivateKey ( hostname , newCert , kp . getPrivate ( ) ) ; thumbprint = ThumbprintUtil . getThumbprint ( newCert ) ; _subjectMap . put ( subject , thumbprint ) ; if ( persistImmediately ) { persist ( ) ; } return newCert ; } return getCertificateByAlias ( thumbprint ) ; }
This method returns the mapped certificate for a hostname or generates a standard SSL server certificate issued by the CA to the supplied subject if no mapping has been created . This is not a true duplication just a shortcut method that is adequate for web browsers .