Java Code Examples for java.security.cert.CertificateException#printStackTrace()

The following examples show how to use java.security.cert.CertificateException#printStackTrace() . 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: TestTrustManager.java    From j2objc with Apache License 2.0 6 votes vote down vote up
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine)
        throws CertificateException {
    if (extendedTrustManager == null) {
        out.print("(fallback to X509TrustManager) ");
        checkServerTrusted(chain, authType);
        return;
    }
    out.print("TestTrustManager.checkServerTrusted "
            + "chain=" + chain.length + " "
            + "authType=" + authType + " "
            + "engine=" + engine.toString() + " ");
    try {
        assertServerAuthType(authType);
        extendedTrustManager.checkServerTrusted(chain, authType, engine);
        out.println("OK");
    } catch (CertificateException e) {
        e.printStackTrace(out);
        throw e;
    }
}
 
Example 2
Source File: TestTrustManager.java    From j2objc with Apache License 2.0 6 votes vote down vote up
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket)
        throws CertificateException {
    if (extendedTrustManager == null) {
        out.print("(fallback to X509TrustManager) ");
        checkClientTrusted(chain, authType);
        return;
    }
    out.print("TestTrustManager.checkClientTrusted "
            + "chain=" + chain.length + " "
            + "authType=" + authType + " "
            + "socket=" + socket + " ");
    try {
        assertClientAuthType(authType);
        extendedTrustManager.checkClientTrusted(chain, authType, socket);
        out.println("OK");
    } catch (CertificateException e) {
        e.printStackTrace(out);
        throw e;
    }
}
 
Example 3
Source File: ConnectedRESTQA.java    From java-client-api with Apache License 2.0 6 votes vote down vote up
public static DatabaseClient getDatabaseClient(String user, String password, Authentication authType)
		throws KeyManagementException, NoSuchAlgorithmException, IOException {
	DatabaseClient client = null;
	try {
		SSLContext sslcontext = null;
		if (IsSecurityEnabled()) {
			sslcontext = getSslContext();
			client = DatabaseClientFactory.newClient(getRestServerHostName(), getRestServerPort(), user, password,
					authType, sslcontext, SSLHostnameVerifier.ANY);
		} else
			client = DatabaseClientFactory.newClient(getRestServerHostName(), getRestServerPort(), user, password,
					authType);
	} catch (CertificateException certEx) {
		// TODO Auto-generated catch block
		certEx.printStackTrace();
	} catch (KeyStoreException ksEx) {
		// TODO Auto-generated catch block
		ksEx.printStackTrace();
	} catch (UnrecoverableKeyException unReovkeyEx) {
		// TODO Auto-generated catch block
		unReovkeyEx.printStackTrace();
	}
	return client;
}
 
Example 4
Source File: X509CertificateFile.java    From offspring with MIT License 5 votes vote down vote up
public static X509Certificate getCertificate(InputStream inStream) {
  try {
    CertificateFactory cf = CertificateFactory.getInstance("X.509");
    X509Certificate cert = (X509Certificate) cf.generateCertificate(inStream);
    return cert;
  }
  catch (CertificateException e) {
    e.printStackTrace(System.err);
  }
  return null;
}
 
Example 5
Source File: PermissiveX509TrustManager.java    From gocd with Apache License 2.0 5 votes vote down vote up
@Override
public void checkServerTrusted(X509Certificate[] certificates, String string) throws CertificateException {
    if ((certificates != null) && (certificates.length == 1)) {
        X509Certificate certificate = certificates[0];

        try {
            certificate.checkValidity();
        } catch (CertificateException e) {
            e.printStackTrace();
        }
    } else {
        this.standardTrustManager.checkServerTrusted(certificates, string);
    }
}
 
Example 6
Source File: bt.java    From letv with Apache License 2.0 5 votes vote down vote up
public static String v(Context context) {
    PackageInfo packageInfo;
    String str = null;
    try {
        packageInfo = context.getPackageManager().getPackageInfo(u(context), 64);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
        Object obj = str;
    }
    InputStream byteArrayInputStream = new ByteArrayInputStream(packageInfo.signatures[0].toByteArray());
    try {
        CertificateFactory instance = CertificateFactory.getInstance("X509");
    } catch (CertificateException e2) {
        e2.printStackTrace();
        obj = str;
    }
    try {
        X509Certificate x509Certificate = (X509Certificate) instance.generateCertificate(byteArrayInputStream);
    } catch (CertificateException e22) {
        e22.printStackTrace();
        obj = str;
    }
    try {
        str = a(MessageDigest.getInstance(CommonUtils.MD5_INSTANCE).digest(x509Certificate.getEncoded()));
    } catch (NoSuchAlgorithmException e3) {
        e3.printStackTrace();
    } catch (CertificateEncodingException e4) {
        e4.printStackTrace();
    }
    return str;
}
 
Example 7
Source File: DirectDownloadManagerImpl.java    From cloudstack with Apache License 2.0 5 votes vote down vote up
/**
 * Generate and return certificate from the string
 * @throws CloudRuntimeException if the certificate is not well formed
 */
private Certificate getCertificateFromString(String certificatePem) {
    try {
        return CertificateHelper.buildCertificate(certificatePem);
    } catch (CertificateException e) {
        e.printStackTrace();
        throw new CloudRuntimeException("Cannot parse the certificate provided, please provide a PEM certificate. Error: " + e.getMessage());
    }
}
 
Example 8
Source File: HttpsUtils.java    From FimiX8-RE with MIT License 5 votes vote down vote up
private static KeyManager[] prepareKeyManager(InputStream bksFile, String password) {
    KeyManager[] keyManagerArr = null;
    if (bksFile == null || password == null) {
        return keyManagerArr;
    }
    try {
        KeyStore clientKeyStore = KeyStore.getInstance("BKS");
        clientKeyStore.load(bksFile, password.toCharArray());
        KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
        keyManagerFactory.init(clientKeyStore, password.toCharArray());
        return keyManagerFactory.getKeyManagers();
    } catch (KeyStoreException e) {
        e.printStackTrace();
        return keyManagerArr;
    } catch (NoSuchAlgorithmException e2) {
        e2.printStackTrace();
        return keyManagerArr;
    } catch (UnrecoverableKeyException e3) {
        e3.printStackTrace();
        return keyManagerArr;
    } catch (CertificateException e4) {
        e4.printStackTrace();
        return keyManagerArr;
    } catch (IOException e5) {
        e5.printStackTrace();
        return keyManagerArr;
    } catch (Exception e6) {
        e6.printStackTrace();
        return keyManagerArr;
    }
}
 
Example 9
Source File: BadFooter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    // The two sections below are identical, a self-signed cert generated
    // for a fake principal:
    // CN=Me, OU=Office, O=A-B-C, L=Backside, ST=Moon, C=EA
    String cert =
    "-----BEGIN CERTIFICATE-----\n" +
    "MIIDGDCCAtWgAwIBAgIERgH/AjALBgcqhkjOOAQDBQAwXTELMAkGA1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aO/O\n" +
    "PYXjk9EfGhikHlnKgC6jITAfMB0GA1UdDgQWBBTtv4rKVwXtXJpyZWlswQL4MAKkazALBgcqhkjO\n" +
    "OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
    "-----END CERTIFICATE-----\n";
    try {
        CertificateFactory.getInstance("X509").generateCertificates(
                new ByteArrayInputStream(cert.getBytes()));
        throw new Exception("Fail. certificate generation should fail");
    } catch (CertificateException ce) {
        ce.printStackTrace();
        // This is the correct result
    }
}
 
Example 10
Source File: BadFooter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    // The two sections below are identical, a self-signed cert generated
    // for a fake principal:
    // CN=Me, OU=Office, O=A-B-C, L=Backside, ST=Moon, C=EA
    String cert =
    "-----BEGIN CERTIFICATE-----\n" +
    "MIIDGDCCAtWgAwIBAgIERgH/AjALBgcqhkjOOAQDBQAwXTELMAkGA1UEBhMCRUExDTALBgNVBAgT\n" +
    "BE1vb24xETAPBgNVBAcTCEJhY2tzaWRlMQ4wDAYDVQQKEwVBLUItQzEPMA0GA1UECxMGT2ZmaWNl\n" +
    "MQswCQYDVQQDEwJNZTAeFw0wNzAzMjIwMzU4NThaFw0wNzA2MjAwMzU4NThaMF0xCzAJBgNVBAYT\n" +
    "AkVBMQ0wCwYDVQQIEwRNb29uMREwDwYDVQQHEwhCYWNrc2lkZTEOMAwGA1UEChMFQS1CLUMxDzAN\n" +
    "BgNVBAsTBk9mZmljZTELMAkGA1UEAxMCTWUwggG4MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11\n" +
    "EilS30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZg\n" +
    "t2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/y\n" +
    "IgMZndFIAccCFQCXYFCPFSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o6\n" +
    "6oL5V0wLPQeCZ1FZV4661FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7Om\n" +
    "dZFuo38L+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBhQACgYEA\n" +
    "xc7ovvDeJ5yIkiEoz6U4jcFf5ZDSC+rUEsqGuARXHUF0PlIth7h2e9KV12cwdjVH++mGvwU/m/Ju\n" +
    "OpaaWOEFRHgCMe5fZ2xE0pWPcmKkPicc85SKHguYTMCc9D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
    "PYXjk9EfGhikHlnKgC6jITAfMB0GA1UdDgQWBBTtv4rKVwXtXJpyZWlswQL4MAKkazALBgcqhkjO\n" +
    "OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
    "-----BEGIN CERTIFICATE-----\n" +
    "MIIDGDCCAtWgAwIBAgIERgH/AjALBgcqhkjOOAQDBQAwXTELMAkGA1UEBhMCRUExDTALBgNVBAgT\n" +
    "BE1vb24xETAPBgNVBAcTCEJhY2tzaWRlMQ4wDAYDVQQKEwVBLUItQzEPMA0GA1UECxMGT2ZmaWNl\n" +
    "MQswCQYDVQQDEwJNZTAeFw0wNzAzMjIwMzU4NThaFw0wNzA2MjAwMzU4NThaMF0xCzAJBgNVBAYT\n" +
    "AkVBMQ0wCwYDVQQIEwRNb29uMREwDwYDVQQHEwhCYWNrc2lkZTEOMAwGA1UEChMFQS1CLUMxDzAN\n" +
    "BgNVBAsTBk9mZmljZTELMAkGA1UEAxMCTWUwggG4MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11\n" +
    "EilS30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZg\n" +
    "t2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/y\n" +
    "IgMZndFIAccCFQCXYFCPFSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o6\n" +
    "6oL5V0wLPQeCZ1FZV4661FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7Om\n" +
    "dZFuo38L+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBhQACgYEA\n" +
    "xc7ovvDeJ5yIkiEoz6U4jcFf5ZDSC+rUEsqGuARXHUF0PlIth7h2e9KV12cwdjVH++mGvwU/m/Ju\n" +
    "OpaaWOEFRHgCMe5fZ2xE0pWPcmKkPicc85SKHguYTMCc9D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
    "PYXjk9EfGhikHlnKgC6jITAfMB0GA1UdDgQWBBTtv4rKVwXtXJpyZWlswQL4MAKkazALBgcqhkjO\n" +
    "OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
    "-----END CERTIFICATE-----\n";
    try {
        CertificateFactory.getInstance("X509").generateCertificates(
                new ByteArrayInputStream(cert.getBytes()));
        throw new Exception("Fail. certificate generation should fail");
    } catch (CertificateException ce) {
        ce.printStackTrace();
        // This is the correct result
    }
}
 
Example 11
Source File: BadFooter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    // The two sections below are identical, a self-signed cert generated
    // for a fake principal:
    // CN=Me, OU=Office, O=A-B-C, L=Backside, ST=Moon, C=EA
    String cert =
    "-----BEGIN CERTIFICATE-----\n" +
    "MIIDGDCCAtWgAwIBAgIERgH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D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
    "PYXjk9EfGhikHlnKgC6jITAfMB0GA1UdDgQWBBTtv4rKVwXtXJpyZWlswQL4MAKkazALBgcqhkjO\n" +
    "OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
    "-----END CERTIFICATE-----\n";
    try {
        CertificateFactory.getInstance("X509").generateCertificates(
                new ByteArrayInputStream(cert.getBytes()));
        throw new Exception("Fail. certificate generation should fail");
    } catch (CertificateException ce) {
        ce.printStackTrace();
        // This is the correct result
    }
}
 
Example 12
Source File: BadFooter.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    // The two sections below are identical, a self-signed cert generated
    // for a fake principal:
    // CN=Me, OU=Office, O=A-B-C, L=Backside, ST=Moon, C=EA
    String cert =
    "-----BEGIN CERTIFICATE-----\n" +
    "MIIDGDCCAtWgAwIBAgIERgH/AjALBgcqhkjOOAQDBQAwXTELMAkGA1UEBhMCRUExDTALBgNVBAgT\n" +
    "BE1vb24xETAPBgNVBAcTCEJhY2tzaWRlMQ4wDAYDVQQKEwVBLUItQzEPMA0GA1UECxMGT2ZmaWNl\n" +
    "MQswCQYDVQQDEwJNZTAeFw0wNzAzMjIwMzU4NThaFw0wNzA2MjAwMzU4NThaMF0xCzAJBgNVBAYT\n" +
    "AkVBMQ0wCwYDVQQIEwRNb29uMREwDwYDVQQHEwhCYWNrc2lkZTEOMAwGA1UEChMFQS1CLUMxDzAN\n" +
    "BgNVBAsTBk9mZmljZTELMAkGA1UEAxMCTWUwggG4MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11\n" +
    "EilS30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZg\n" +
    "t2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTx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30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZg\n" +
    "t2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/y\n" +
    "IgMZndFIAccCFQCXYFCPFSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o6\n" +
    "6oL5V0wLPQeCZ1FZV4661FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7Om\n" +
    "dZFuo38L+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBhQACgYEA\n" +
    "xc7ovvDeJ5yIkiEoz6U4jcFf5ZDSC+rUEsqGuARXHUF0PlIth7h2e9KV12cwdjVH++mGvwU/m/Ju\n" +
    "OpaaWOEFRHgCMe5fZ2xE0pWPcmKkPicc85SKHguYTMCc9D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
    "PYXjk9EfGhikHlnKgC6jITAfMB0GA1UdDgQWBBTtv4rKVwXtXJpyZWlswQL4MAKkazALBgcqhkjO\n" +
    "OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
    "-----END CERTIFICATE-----\n";
    try {
        CertificateFactory.getInstance("X509").generateCertificates(
                new ByteArrayInputStream(cert.getBytes()));
        throw new Exception("Fail. certificate generation should fail");
    } catch (CertificateException ce) {
        ce.printStackTrace();
        // This is the correct result
    }
}
 
Example 13
Source File: BadFooter.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    // The two sections below are identical, a self-signed cert generated
    // for a fake principal:
    // CN=Me, OU=Office, O=A-B-C, L=Backside, ST=Moon, C=EA
    String cert =
    "-----BEGIN CERTIFICATE-----\n" +
    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E0pWPcmKkPicc85SKHguYTMCc9D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
    "PYXjk9EfGhikHlnKgC6jITAfMB0GA1UdDgQWBBTtv4rKVwXtXJpyZWlswQL4MAKkazALBgcqhkjO\n" +
    "OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
    "-----END CERTIFICATE-----\n";
    try {
        CertificateFactory.getInstance("X509").generateCertificates(
                new ByteArrayInputStream(cert.getBytes()));
        throw new Exception("Fail. certificate generation should fail");
    } catch (CertificateException ce) {
        ce.printStackTrace();
        // This is the correct result
    }
}
 
Example 14
Source File: BadFooter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    // The two sections below are identical, a self-signed cert generated
    // for a fake principal:
    // CN=Me, OU=Office, O=A-B-C, L=Backside, ST=Moon, C=EA
    String cert =
    "-----BEGIN CERTIFICATE-----\n" +
    "MIIDGDCCAtWgAwIBAgIERgH/AjALBgcqhkjOOAQDBQAwXTELMAkGA1UEBhMCRUExDTALBgNVBAgT\n" +
    "BE1vb24xETAPBgNVBAcTCEJhY2tzaWRlMQ4wDAYDVQQKEwVBLUItQzEPMA0GA1UECxMGT2ZmaWNl\n" +
    "MQswCQYDVQQDEwJNZTAeFw0wNzAzMjIwMzU4NThaFw0wNzA2MjAwMzU4NThaMF0xCzAJBgNVBAYT\n" +
    "AkVBMQ0wCwYDVQQIEwRNb29uMREwDwYDVQQHEwhCYWNrc2lkZTEOMAwGA1UEChMFQS1CLUMxDzAN\n" +
    "BgNVBAsTBk9mZmljZTELMAkGA1UEAxMCTWUwggG4MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11\n" +
    "EilS30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZg\n" +
    "t2uZUKWkn5/oBHsQIsJPu6n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CAR8CgYEA/X9TgR11\n" +
    "EilS30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZg\n" +
    "t2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/y\n" +
    "IgMZndFIAccCFQCXYFCPFSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o6\n" +
    "6oL5V0wLPQeCZ1FZV4661FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7Om\n" +
    "dZFuo38L+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBhQACgYEA\n" +
    "xc7ovvDeJ5yIkiEoz6U4jcFf5ZDSC+rUEsqGuARXHUF0PlIth7h2e9KV12cwdjVH++mGvwU/m/Ju\n" +
    "OpaaWOEFRHgCMe5fZ2xE0pWPcmKkPicc85SKHguYTMCc9D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
    "PYXjk9EfGhikHlnKgC6jITAfMB0GA1UdDgQWBBTtv4rKVwXtXJpyZWlswQL4MAKkazALBgcqhkjO\n" +
    "OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
    "-----END CERTIFICATE-----\n";
    try {
        CertificateFactory.getInstance("X509").generateCertificates(
                new ByteArrayInputStream(cert.getBytes()));
        throw new Exception("Fail. certificate generation should fail");
    } catch (CertificateException ce) {
        ce.printStackTrace();
        // This is the correct result
    }
}
 
Example 15
Source File: BadFooter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    // The two sections below are identical, a self-signed cert generated
    // for a fake principal:
    // CN=Me, OU=Office, O=A-B-C, L=Backside, ST=Moon, C=EA
    String cert =
    "-----BEGIN CERTIFICATE-----\n" +
    "MIIDGDCCAtWgAwIBAgIERgH/AjALBgcqhkjOOAQDBQAwXTELMAkGA1UEBhMCRUExDTALBgNVBAgT\n" +
    "BE1vb24xETAPBgNVBAcTCEJhY2tzaWRlMQ4wDAYDVQQKEwVBLUItQzEPMA0GA1UECxMGT2ZmaWNl\n" +
    "MQswCQYDVQQDEwJNZTAeFw0wNzAzMjIwMzU4NThaFw0wNzA2MjAwMzU4NThaMF0xCzAJBgNVBAYT\n" +
    "AkVBMQ0wCwYDVQQIEwRNb29uMREwDwYDVQQHEwhCYWNrc2lkZTEOMAwGA1UEChMFQS1CLUMxDzAN\n" +
    "BgNVBAsTBk9mZmljZTELMAkGA1UEAxMCTWUwggG4MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11\n" +
    "EilS30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZg\n" +
    "t2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/y\n" +
    "IgMZndFIAccCFQCXYFCPFSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o6\n" +
    "6oL5V0wLPQeCZ1FZV4661FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7Om\n" +
    "dZFuo38L+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBhQACgYEA\n" +
    "xc7ovvDeJ5yIkiEoz6U4jcFf5ZDSC+rUEsqGuARXHUF0PlIth7h2e9KV12cwdjVH++mGvwU/m/Ju\n" +
    "OpaaWOEFRHgCMe5fZ2xE0pWPcmKkPicc85SKHguYTMCc9D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
    "PYXjk9EfGhikHlnKgC6jITAfMB0GA1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/Ju\n" +
    "OpaaWOEFRHgCMe5fZ2xE0pWPcmKkPicc85SKHguYTMCc9D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
    "PYXjk9EfGhikHlnKgC6jITAfMB0GA1UdDgQWBBTtv4rKVwXtXJpyZWlswQL4MAKkazALBgcqhkjO\n" +
    "OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
    "-----END CERTIFICATE-----\n";
    try {
        CertificateFactory.getInstance("X509").generateCertificates(
                new ByteArrayInputStream(cert.getBytes()));
        throw new Exception("Fail. certificate generation should fail");
    } catch (CertificateException ce) {
        ce.printStackTrace();
        // This is the correct result
    }
}
 
Example 16
Source File: BadFooter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    // The two sections below are identical, a self-signed cert generated
    // for a fake principal:
    // CN=Me, OU=Office, O=A-B-C, L=Backside, ST=Moon, C=EA
    String cert =
    "-----BEGIN CERTIFICATE-----\n" +
    "MIIDGDCCAtWgAwIBAgIERgH/AjALBgcqhkjOOAQDBQAwXTELMAkGA1UEBhMCRUExDTALBgNVBAgT\n" +
    "BE1vb24xETAPBgNVBAcTCEJhY2tzaWRlMQ4wDAYDVQQKEwVBLUItQzEPMA0GA1UECxMGT2ZmaWNl\n" +
    "MQswCQYDVQQDEwJNZTAeFw0wNzAzMjIwMzU4NThaFw0wNzA2MjAwMzU4NThaMF0xCzAJBgNVBAYT\n" +
    "AkVBMQ0wCwYDVQQIEwRNb29uMREwDwYDVQQHEwhCYWNrc2lkZTEOMAwGA1UEChMFQS1CLUMxDzAN\n" +
    "BgNVBAsTBk9mZmljZTELMAkGA1UEAxMCTWUwggG4MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11\n" +
    "EilS30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZ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UEAxMCTWUwggG4MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11\n" +
    "EilS30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZg\n" +
    "t2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/y\n" +
    "IgMZndFIAccCFQCXYFCPFSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o6\n" +
    "6oL5V0wLPQeCZ1FZV4661FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7Om\n" +
    "dZFuo38L+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBhQACgYEA\n" +
    "xc7ovvDeJ5yIkiEoz6U4jcFf5ZDSC+rUEsqGuARXHUF0PlIth7h2e9KV12cwdjVH++mGvwU/m/Ju\n" +
    "OpaaWOEFRHgCMe5fZ2xE0pWPcmKkPicc85SKHguYTMCc9D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
    "PYXjk9EfGhikHlnKgC6jITAfMB0GA1UdDgQWBBTtv4rKVwXtXJpyZWlswQL4MAKkazALBgcqhkjO\n" +
    "OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
    "-----END CERTIFICATE-----\n";
    try {
        CertificateFactory.getInstance("X509").generateCertificates(
                new ByteArrayInputStream(cert.getBytes()));
        throw new Exception("Fail. certificate generation should fail");
    } catch (CertificateException ce) {
        ce.printStackTrace();
        // This is the correct result
    }
}
 
Example 17
Source File: BadFooter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    // The two sections below are identical, a self-signed cert generated
    // for a fake principal:
    // CN=Me, OU=Office, O=A-B-C, L=Backside, ST=Moon, C=EA
    String cert =
    "-----BEGIN CERTIFICATE-----\n" +
    "MIIDGDCCAtWgAwIBAgIERgH/AjALBgcqhkjOOAQDBQAwXTELMAkGA1UEBhMCRUExDTALBgNVBAgT\n" +
    "BE1vb24xETAPBgNVBAcTCEJhY2tzaWRlMQ4wDAYDVQQKEwVBLUItQzEPMA0GA1UECxMGT2ZmaWNl\n" +
    "MQswCQYDVQQDEwJNZTAeFw0wNzAzMjIwMzU4NThaFw0wNzA2MjAwMzU4NThaMF0xCzAJBgNVBAYT\n" +
    "AkVBMQ0wCwYDVQQIEwRNb29uMREwDwYDVQQHEwhCYWNrc2lkZTEOMAwGA1UEChMFQS1CLUMxDzAN\n" +
    "BgNVBAsTBk9mZmljZTELMAkGA1UEAxMCTWUwggG4MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11\n" +
    "EilS30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZg\n" +
    "t2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/y\n" +
    "IgMZndFIAccCFQCXYFCPFSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o6\n" +
    "6oL5V0wLPQeCZ1FZV4661FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7Om\n" +
    "dZFuo38L+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBhQACgYEA\n" +
    "xc7ovvDeJ5yIkiEoz6U4jcFf5ZDSC+rUEsqGuARXHUF0PlIth7h2e9KV12cwdjVH++mGvwU/m/Ju\n" +
    "OpaaWOEFRHgCMe5fZ2xE0pWPcmKkPicc85SKHguYTMCc9D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
    "PYX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lIth7h2e9KV12cwdjVH++mGvwU/m/Ju\n" +
    "OpaaWOEFRHgCMe5fZ2xE0pWPcmKkPicc85SKHguYTMCc9D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
    "PYXjk9EfGhikHlnKgC6jITAfMB0GA1UdDgQWBBTtv4rKVwXtXJpyZWlswQL4MAKkazALBgcqhkjO\n" +
    "OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
    "-----END CERTIFICATE-----\n";
    try {
        CertificateFactory.getInstance("X509").generateCertificates(
                new ByteArrayInputStream(cert.getBytes()));
        throw new Exception("Fail. certificate generation should fail");
    } catch (CertificateException ce) {
        ce.printStackTrace();
        // This is the correct result
    }
}
 
Example 18
Source File: OPC_Server.java    From ICS-TestBed-Framework with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreateSession(EndpointServiceRequest<CreateSessionRequest, CreateSessionResponse> msgExchange)
        throws ServiceFaultException {
    CreateSessionRequest request = msgExchange.getRequest();
    CreateSessionResponse response = new CreateSessionResponse();

    StatusCode statusCode = null;
    byte[] token = new byte[32];
    byte[] nonce = new byte[32];
    Random r = new Random();
    r.nextBytes(nonce);
    r.nextBytes(token);

    // Check client nonce
    ByteString clientNonce = request.getClientNonce();
    if (clientNonce != null) {
        if (clientNonce.getLength() < 32) {
            statusCode = new StatusCode(StatusCodes.Bad_NonceInvalid);
        }
    }
    ByteString clientCertificate = request.getClientCertificate();
    if (clientCertificate != null) {
        String clientApplicationUri = request.getClientDescription().getApplicationUri();
        X509Certificate clientCertificateDecoded = null;
        String applicationUriOfDecoded = null;
        try {
            clientCertificateDecoded = CertificateUtils.decodeX509Certificate(clientCertificate.getValue());
            applicationUriOfDecoded = CertificateUtils.getApplicationUriOfCertificate(clientCertificateDecoded);
        } catch (CertificateException e) {
            e.printStackTrace();
        }

        if (!clientApplicationUri.equals(applicationUriOfDecoded)) {
            statusCode = new StatusCode(StatusCodes.Bad_CertificateUriInvalid);
        }
    }

    if (statusCode == null) {

        EndpointConfiguration endpointConfiguration = EndpointConfiguration.defaults();
        response.setMaxRequestMessageSize(UnsignedInteger.valueOf(
                Math.max(endpointConfiguration.getMaxMessageSize(), request.getMaxResponseMessageSize().longValue())));

        Double timeout = new Double(60 * 1000);
        if (!request.getRequestedSessionTimeout().equals(new Double(0))) {
            // set revised session timeout to 60 seconds or to lower
            // value if client requests
            timeout = Math.min(request.getRequestedSessionTimeout(), 60 * 1000);
        }
        response.setRevisedSessionTimeout(timeout);

        NodeId tokenId = new NodeId(0, token);
        response.setAuthenticationToken(tokenId);
        // Put authentication to memory in order to check validity of
        // incoming authentication tokens
        sessions.add(tokenId);
        Long time = System.currentTimeMillis();
        timeoutPeriods.put(tokenId, time + timeout.longValue());
    }

    KeyPair cert = getApplication().getApplicationInstanceCertificates()[0];
    response.setServerCertificate(ByteString.valueOf(cert.getCertificate().getEncoded()));
    response.setServerEndpoints(this.getEndpointDescriptions());
    response.setServerNonce(ByteString.valueOf(nonce));

    SecurityPolicy securityPolicy = msgExchange.getChannel().getSecurityPolicy();
    response.setServerSignature(
            getServerSignature(clientCertificate, clientNonce, securityPolicy, cert.getPrivateKey().getPrivateKey()));

    response.setServerSoftwareCertificates(getApplication().getSoftwareCertificates());
    response.setSessionId(new NodeId(0, "Session-" + UUID.randomUUID()));

    if (statusCode == null) {
        statusCode = StatusCode.GOOD;
    }
    // Set response header
    ResponseHeader h = new ResponseHeader(DateTime.currentTime(), request.getRequestHeader().getRequestHandle(),
            statusCode, null, getApplication().getLocaleIds(), null);
    response.setResponseHeader(h);

    msgExchange.sendResponse(response);
}
 
Example 19
Source File: BadFooter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    // The two sections below are identical, a self-signed cert generated
    // for a fake principal:
    // CN=Me, OU=Office, O=A-B-C, L=Backside, ST=Moon, C=EA
    String cert =
    "-----BEGIN CERTIFICATE-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lswQL4MAKkazALBgcqhkjO\n" +
    "OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
    "-----BEGIN CERTIFICATE-----\n" +
    "MIIDGDCCAtWgAwIBAgIERgH/AjALBgcqhkjOOAQDBQAwXTELMAkGA1UEBhMCRUExDTALBgNVBAgT\n" +
    "BE1vb24xETAPBgNVBAcTCEJhY2tzaWRlMQ4wDAYDVQQKEwVBLUItQzEPMA0GA1UECxMGT2ZmaWNl\n" +
    "MQswCQYDVQQDEwJNZTAeFw0wNzAzMjIwMzU4NThaFw0wNzA2MjAwMzU4NThaMF0xCzAJBgNVBAYT\n" +
    "AkVBMQ0wCwYDVQQIEwRNb29uMREwDwYDVQQHEwhCYWNrc2lkZTEOMAwGA1UEChMFQS1CLUMxDzAN\n" +
    "BgNVBAsTBk9mZmljZTELMAkGA1UEAxMCTWUwggG4MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11\n" +
    "EilS30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZg\n" +
    "t2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/y\n" +
    "IgMZndFIAccCFQCXYFCPFSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o6\n" +
    "6oL5V0wLPQeCZ1FZV4661FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7Om\n" +
    "dZFuo38L+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBhQACgYEA\n" +
    "xc7ovvDeJ5yIkiEoz6U4jcFf5ZDSC+rUEsqGuARXHUF0PlIth7h2e9KV12cwdjVH++mGvwU/m/Ju\n" +
    "OpaaWOEFRHgCMe5fZ2xE0pWPcmKkPicc85SKHguYTMCc9D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
    "PYXjk9EfGhikHlnKgC6jITAfMB0GA1UdDgQWBBTtv4rKVwXtXJpyZWlswQL4MAKkazALBgcqhkjO\n" +
    "OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
    "-----END CERTIFICATE-----\n";
    try {
        CertificateFactory.getInstance("X509").generateCertificates(
                new ByteArrayInputStream(cert.getBytes()));
        throw new Exception("Fail. certificate generation should fail");
    } catch (CertificateException ce) {
        ce.printStackTrace();
        // This is the correct result
    }
}
 
Example 20
Source File: BadFooter.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    // The two sections below are identical, a self-signed cert generated
    // for a fake principal:
    // CN=Me, OU=Office, O=A-B-C, L=Backside, ST=Moon, C=EA
    String cert =
    "-----BEGIN CERTIFICATE-----\n" +
    "MIIDGDCCAtWgAwIBAgIERgH/AjALBgcqhkjOOAQDBQAwXTELMAkGA1UEBhMCRUExDTALBgNVBAgT\n" +
    "BE1vb24xETAPBgNVBAcTCEJhY2tzaWRlMQ4wDAYDVQQKEwVBLUItQzEPMA0GA1UECxMGT2ZmaWNl\n" +
    "MQswCQYDVQQDEwJNZTAeFw0wNzAzMjIwMzU4NThaFw0wNzA2MjAwMzU4NThaMF0xCzAJBgNVBAYT\n" +
    "AkVBMQ0wCwYDVQQIEwRNb29uMREwDwYDVQQHEwhCYWNrc2lkZTEOMAwGA1UEChMFQS1CLUMxDzAN\n" +
    "BgNVBAsTBk9mZmljZTELMAkGA1UEAxMCTWUwggG4MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11\n" +
    "EilS30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZg\n" +
    "t2uZUKWkn5/oBHsQ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IzjgEATCCAR8CgYEA/X9TgR11\n" +
    "EilS30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZg\n" +
    "t2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/y\n" +
    "IgMZndFIAccCFQCXYFCPFSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o6\n" +
    "6oL5V0wLPQeCZ1FZV4661FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7Om\n" +
    "dZFuo38L+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBhQACgYEA\n" +
    "xc7ovvDeJ5yIkiEoz6U4jcFf5ZDSC+rUEsqGuARXHUF0PlIth7h2e9KV12cwdjVH++mGvwU/m/Ju\n" +
    "OpaaWOEFRHgCMe5fZ2xE0pWPcmKkPicc85SKHguYTMCc9D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
    "PYXjk9EfGhikHlnKgC6jITAfMB0GA1UdDgQWBBTtv4rKVwXtXJpyZWlswQL4MAKkazALBgcqhkjO\n" +
    "OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
    "-----END CERTIFICATE-----\n";
    try {
        CertificateFactory.getInstance("X509").generateCertificates(
                new ByteArrayInputStream(cert.getBytes()));
        throw new Exception("Fail. certificate generation should fail");
    } catch (CertificateException ce) {
        ce.printStackTrace();
        // This is the correct result
    }
}