net.lightbody.bmp.mitm.util.KeyStoreUtil Java Examples

The following examples show how to use net.lightbody.bmp.mitm.util.KeyStoreUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultSecurityProviderTool.java    From CapturePacket with MIT License 5 votes vote down vote up
@Override
public KeyStore createServerKeyStore(String keyStoreType,
                                     CertificateAndKey serverCertificateAndKey,
                                     X509Certificate rootCertificate,
                                     String privateKeyAlias,
                                     String password) {
    if (password == null) {
        throw new IllegalArgumentException("KeyStore password cannot be null");
    }

    if (privateKeyAlias == null) {
        throw new IllegalArgumentException("Private key alias cannot be null");
    }

    // create a KeyStore containing the impersonated certificate's private key and a certificate chain with the
    // impersonated cert and our root certificate
    KeyStore impersonatedCertificateKeyStore = KeyStoreUtil.createEmptyKeyStore(keyStoreType, null);

    // create the certificate chain back for the impersonated certificate back to the root certificate
    Certificate[] chain = {serverCertificateAndKey.getCertificate(), rootCertificate};

    try {
        // place the impersonated certificate and its private key in the KeyStore
        impersonatedCertificateKeyStore.setKeyEntry(privateKeyAlias, serverCertificateAndKey.getPrivateKey(), password.toCharArray(), chain);
    } catch (KeyStoreException e) {
        throw new KeyStoreAccessException("Error storing impersonated certificate and private key in KeyStore", e);
    }

    return impersonatedCertificateKeyStore;
}
 
Example #2
Source File: DefaultSecurityProviderTool.java    From Dream-Catcher with MIT License 5 votes vote down vote up
@Override
public KeyStore createServerKeyStore(String keyStoreType,
                                     CertificateAndKey serverCertificateAndKey,
                                     X509Certificate rootCertificate,
                                     String privateKeyAlias,
                                     String password) {
    if (password == null) {
        throw new IllegalArgumentException("KeyStore password cannot be null");
    }

    if (privateKeyAlias == null) {
        throw new IllegalArgumentException("Private key alias cannot be null");
    }

    // create a KeyStore containing the impersonated certificate's private key and a certificate chain with the
    // impersonated cert and our root certificate
    KeyStore impersonatedCertificateKeyStore = KeyStoreUtil.createEmptyKeyStore(keyStoreType, null);

    // create the certificate chain back for the impersonated certificate back to the root certificate
    Certificate[] chain = {serverCertificateAndKey.getCertificate(), rootCertificate};

    try {
        // place the impersonated certificate and its private key in the KeyStore
        impersonatedCertificateKeyStore.setKeyEntry(privateKeyAlias, serverCertificateAndKey.getPrivateKey(), password.toCharArray(), chain);
    } catch (KeyStoreException e) {
        throw new KeyStoreAccessException("Error storing impersonated certificate and private key in KeyStore", e);
    }

    return impersonatedCertificateKeyStore;
}
 
Example #3
Source File: DefaultSecurityProviderTool.java    From AndroidHttpCapture with MIT License 5 votes vote down vote up
@Override
public KeyStore createServerKeyStore(String keyStoreType,
                                     CertificateAndKey serverCertificateAndKey,
                                     X509Certificate rootCertificate,
                                     String privateKeyAlias,
                                     String password) {
    if (password == null) {
        throw new IllegalArgumentException("KeyStore password cannot be null");
    }

    if (privateKeyAlias == null) {
        throw new IllegalArgumentException("Private key alias cannot be null");
    }

    // create a KeyStore containing the impersonated certificate's private key and a certificate chain with the
    // impersonated cert and our root certificate
    KeyStore impersonatedCertificateKeyStore = KeyStoreUtil.createEmptyKeyStore(keyStoreType, null);

    // create the certificate chain back for the impersonated certificate back to the root certificate
    Certificate[] chain = {serverCertificateAndKey.getCertificate(), rootCertificate};

    try {
        // place the impersonated certificate and its private key in the KeyStore
        impersonatedCertificateKeyStore.setKeyEntry(privateKeyAlias, serverCertificateAndKey.getPrivateKey(), password.toCharArray(), chain);
    } catch (KeyStoreException e) {
        throw new KeyStoreAccessException("Error storing impersonated certificate and private key in KeyStore", e);
    }

    return impersonatedCertificateKeyStore;
}
 
Example #4
Source File: DefaultSecurityProviderTool.java    From CapturePacket with MIT License 4 votes vote down vote up
@Override
public KeyStore createRootCertificateKeyStore(String keyStoreType, CertificateAndKey rootCertificateAndKey, String privateKeyAlias, String password) {
    return KeyStoreUtil.createRootCertificateKeyStore(keyStoreType, rootCertificateAndKey.getCertificate(), privateKeyAlias, rootCertificateAndKey.getPrivateKey(), password, null);
}
 
Example #5
Source File: DefaultSecurityProviderTool.java    From CapturePacket with MIT License 4 votes vote down vote up
@Override
public KeyManager[] getKeyManagers(KeyStore keyStore, String keyStorePassword) {
    return KeyStoreUtil.getKeyManagers(keyStore, keyStorePassword, null, null);
}
 
Example #6
Source File: DefaultSecurityProviderTool.java    From Dream-Catcher with MIT License 4 votes vote down vote up
@Override
public KeyStore createRootCertificateKeyStore(String keyStoreType, CertificateAndKey rootCertificateAndKey, String privateKeyAlias, String password) {
    return KeyStoreUtil.createRootCertificateKeyStore(keyStoreType, rootCertificateAndKey.getCertificate(), privateKeyAlias, rootCertificateAndKey.getPrivateKey(), password, null);
}
 
Example #7
Source File: DefaultSecurityProviderTool.java    From Dream-Catcher with MIT License 4 votes vote down vote up
@Override
public KeyManager[] getKeyManagers(KeyStore keyStore, String keyStorePassword) {
    return KeyStoreUtil.getKeyManagers(keyStore, keyStorePassword, null, null);
}
 
Example #8
Source File: DefaultSecurityProviderTool.java    From AndroidHttpCapture with MIT License 4 votes vote down vote up
@Override
public KeyStore createRootCertificateKeyStore(String keyStoreType, CertificateAndKey rootCertificateAndKey, String privateKeyAlias, String password) {
    return KeyStoreUtil.createRootCertificateKeyStore(keyStoreType, rootCertificateAndKey.getCertificate(), privateKeyAlias, rootCertificateAndKey.getPrivateKey(), password, null);
}
 
Example #9
Source File: DefaultSecurityProviderTool.java    From AndroidHttpCapture with MIT License 4 votes vote down vote up
@Override
public KeyManager[] getKeyManagers(KeyStore keyStore, String keyStorePassword) {
    return KeyStoreUtil.getKeyManagers(keyStore, keyStorePassword, null, null);
}