public class KeyStoreManager extends Object
Modifier and Type | Field and Description |
---|---|
static String |
_caPrivKeyAlias |
String |
DSA_KEYGEN_ALGO |
String |
RSA_KEYGEN_ALGO |
Constructor and Description |
---|
KeyStoreManager(File root) |
Modifier and Type | Method and Description |
---|---|
void |
addCertAndPrivateKey(String hostname,
X509Certificate cert,
PrivateKey privKey)
Stores a new certificate and its associated private key in the keystore.
|
protected void |
createKeystore()
Creates, writes and loads a new keystore and CA root certificate.
|
X509Certificate |
getCertificateByAlias(String alias)
Returns the aliased certificate.
|
X509Certificate |
getCertificateByHostname(String hostname)
Returns the aliased certificate.
|
KeyStore |
getKeyStore() |
X509Certificate |
getMappedCertificateForHostname(String hostname)
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.
|
PublicKey |
getMappedPublicKey(PublicKey original)
If we get a KeyValue with a given public key, then
later see an X509Data with the same public key, we shouldn't split this
in our MITM impl.
|
boolean |
getPersistImmediately()
Whether updates are immediately written to disk.
|
PrivateKey |
getPrivateKey(PublicKey pk)
Returns the private key for a public key we have generated.
|
PrivateKey |
getPrivateKeyForLocalCert(X509Certificate cert)
For a cert we have generated, return the private key.
|
X509Certificate |
getSigningCert()
Gets the authority root signing cert.
|
PrivateKey |
getSigningPrivateKey()
Gets the authority private signing key.
|
void |
mapPublicKeys(PublicKey original,
PublicKey substitute)
Stores a public key mapping.
|
void |
persist()
Writes the keystore and certificate/keypair mappings to disk.
|
void |
setPersistImmediately(boolean persistImmediately)
Whether updates are immediately written to disk.
|
public static final String _caPrivKeyAlias
public final String RSA_KEYGEN_ALGO
public final String DSA_KEYGEN_ALGO
public KeyStoreManager(File root)
protected void createKeystore()
public void addCertAndPrivateKey(String hostname, X509Certificate cert, PrivateKey privKey) throws KeyStoreException, CertificateException, NoSuchAlgorithmException
hostname
- cert
- privKey
- @throws KeyStoreExceptionCertificateException
NoSuchAlgorithmException
KeyStoreException
public void persist() throws KeyStoreException, NoSuchAlgorithmException, CertificateException
public X509Certificate getCertificateByAlias(String alias) throws KeyStoreException
alias
- KeyStoreException
ThumbprintUtil
public X509Certificate getCertificateByHostname(String hostname) throws KeyStoreException, CertificateParsingException, InvalidKeyException, CertificateExpiredException, CertificateNotYetValidException, SignatureException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException, UnrecoverableKeyException
public X509Certificate getSigningCert() throws KeyStoreException
KeyStoreException
public PrivateKey getSigningPrivateKey() throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException
KeyStoreException
NoSuchAlgorithmException
UnrecoverableKeyException
public boolean getPersistImmediately()
public void setPersistImmediately(boolean persistImmediately)
persistImmediately
- public X509Certificate getMappedCertificateForHostname(String hostname) throws CertificateParsingException, InvalidKeyException, CertificateExpiredException, CertificateNotYetValidException, SignatureException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException, KeyStoreException, UnrecoverableKeyException
public PrivateKey getPrivateKeyForLocalCert(X509Certificate cert) throws CertificateEncodingException, KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException
cert
- CertificateEncodingException
KeyStoreException
UnrecoverableKeyException
NoSuchAlgorithmException
public void mapPublicKeys(PublicKey original, PublicKey substitute)
original
- substitute
- public PublicKey getMappedPublicKey(PublicKey original)
public PrivateKey getPrivateKey(PublicKey pk)
pk
- public KeyStore getKeyStore()
Copyright © 2016. All Rights Reserved.