jdk/test/javax/net/ssl/TLSv12/DisabledShortRSAKeys.java
author prr
Thu, 18 Dec 2014 10:45:45 -0800
changeset 29908 83e2c403fefd
parent 23052 241885315119
child 42990 9edd5241610a
permissions -rw-r--r--
8067050: Better font consistency checking Reviewed-by: bae, srl, mschoene
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14929
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
     1
/*
21658
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
     2
 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
14929
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
     4
 *
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    10
 *
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    15
 * accompanied this code).
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    16
 *
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    20
 *
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    23
 * questions.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    24
 */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    25
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    26
// SunJSSE does not support dynamic system properties, no way to re-use
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    27
// system properties in samevm/agentvm mode.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    28
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    29
/*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    30
 * @test
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    31
 * @bug 7109274
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    32
 * @summary Consider disabling support for X.509 certificates with RSA keys
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    33
 *          less than 1024 bits
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    34
 *
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    35
 * @run main/othervm DisabledShortRSAKeys PKIX TLSv1.2
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    36
 * @run main/othervm DisabledShortRSAKeys SunX509 TLSv1.2
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    37
 * @run main/othervm DisabledShortRSAKeys PKIX TLSv1.1
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    38
 * @run main/othervm DisabledShortRSAKeys SunX509 TLSv1.1
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    39
 * @run main/othervm DisabledShortRSAKeys PKIX TLSv1
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    40
 * @run main/othervm DisabledShortRSAKeys SunX509 TLSv1
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    41
 * @run main/othervm DisabledShortRSAKeys PKIX SSLv3
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    42
 * @run main/othervm DisabledShortRSAKeys SunX509 SSLv3
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    43
 */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    44
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    45
import java.net.*;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    46
import java.util.*;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    47
import java.io.*;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    48
import javax.net.ssl.*;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    49
import java.security.Security;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    50
import java.security.KeyStore;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    51
import java.security.KeyFactory;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    52
import java.security.cert.Certificate;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    53
import java.security.cert.CertificateFactory;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    54
import java.security.spec.*;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    55
import java.security.interfaces.*;
16020
b57c48f16179 8006182: cleanup to use java.util.Base64 in java security component, providers, and regression tests
msheppar
parents: 14929
diff changeset
    56
import java.util.Base64;
14929
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    57
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    58
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    59
public class DisabledShortRSAKeys {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    60
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    61
    /*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    62
     * =============================================================
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    63
     * Set the various variables needed for the tests, then
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    64
     * specify what tests to run on each side.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    65
     */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    66
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    67
    /*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    68
     * Should we run the client or server in a separate thread?
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    69
     * Both sides can throw exceptions, but do you have a preference
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    70
     * as to which side should be the main thread.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    71
     */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    72
    static boolean separateServerThread = true;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    73
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    74
    /*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    75
     * Where do we find the keystores?
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    76
     */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    77
    // Certificates and key used in the test.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    78
    static String trustedCertStr =
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    79
        "-----BEGIN CERTIFICATE-----\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    80
        "MIICkjCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADA7MQswCQYDVQQGEwJVUzEN\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    81
        "MAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UwHhcN\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    82
        "MTEwODE5MDE1MjE5WhcNMzIwNzI5MDE1MjE5WjA7MQswCQYDVQQGEwJVUzENMAsG\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    83
        "A1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UwgZ8wDQYJ\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    84
        "KoZIhvcNAQEBBQADgY0AMIGJAoGBAM8orG08DtF98TMSscjGsidd1ZoN4jiDpi8U\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    85
        "ICz+9dMm1qM1d7O2T+KH3/mxyox7Rc2ZVSCaUD0a3CkhPMnlAx8V4u0H+E9sqso6\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    86
        "iDW3JpOyzMExvZiRgRG/3nvp55RMIUV4vEHOZ1QbhuqG4ebN0Vz2DkRft7+flthf\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    87
        "vDld6f5JAgMBAAGjgaUwgaIwHQYDVR0OBBYEFLl81dnfp0wDrv0OJ1sxlWzH83Xh\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    88
        "MGMGA1UdIwRcMFqAFLl81dnfp0wDrv0OJ1sxlWzH83XhoT+kPTA7MQswCQYDVQQG\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    89
        "EwJVUzENMAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    90
        "Y2WCAQAwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAQYwDQYJKoZIhvcNAQEE\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    91
        "BQADgYEALlgaH1gWtoBZ84EW8Hu6YtGLQ/L9zIFmHonUPZwn3Pr//icR9Sqhc3/l\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    92
        "pVTxOINuFHLRz4BBtEylzRIOPzK3tg8XwuLb1zd0db90x3KBCiAL6E6cklGEPwLe\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    93
        "XYMHDn9eDsaq861Tzn6ZwzMgw04zotPMoZN0mVd/3Qca8UJFucE=\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    94
        "-----END CERTIFICATE-----";
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    95
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    96
    static String targetCertStr =
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    97
        "-----BEGIN CERTIFICATE-----\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    98
        "MIICNDCCAZ2gAwIBAgIBDDANBgkqhkiG9w0BAQQFADA7MQswCQYDVQQGEwJVUzEN\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
    99
        "MAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UwHhcN\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   100
        "MTExMTA3MTM1NTUyWhcNMzEwNzI1MTM1NTUyWjBPMQswCQYDVQQGEwJVUzENMAsG\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   101
        "A1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UxEjAQBgNV\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   102
        "BAMTCWxvY2FsaG9zdDBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQC3Pb49OSPfOD2G\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   103
        "HSXFCFx1GJEZfqG9ZUf7xuIi/ra5dLjPGAaoY5QF2QOa8VnOriQCXDfyXHxsuRnE\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   104
        "OomxL7EVAgMBAAGjeDB2MAsGA1UdDwQEAwID6DAdBgNVHQ4EFgQUXNCJK3/dtCIc\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   105
        "xb+zlA/JINlvs/MwHwYDVR0jBBgwFoAUuXzV2d+nTAOu/Q4nWzGVbMfzdeEwJwYD\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   106
        "VR0lBCAwHgYIKwYBBQUHAwEGCCsGAQUFBwMCBggrBgEFBQcDAzANBgkqhkiG9w0B\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   107
        "AQQFAAOBgQB2qIDUxA2caMPpGtUACZAPRUtrGssCINIfItETXJZCx/cRuZ5sP4D9\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   108
        "N1acoNDn0hCULe3lhXAeTC9NZ97680yJzregQMV5wATjo1FGsKY30Ma+sc/nfzQW\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   109
        "+h/7RhYtoG0OTsiaDCvyhI6swkNJzSzrAccPY4+ZgU8HiDLzZTmM3Q==\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   110
        "-----END CERTIFICATE-----";
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   111
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   112
    // Private key in the format of PKCS#8, key size is 512 bits.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   113
    static String targetPrivateKey =
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   114
        "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAtz2+PTkj3zg9hh0l\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   115
        "xQhcdRiRGX6hvWVH+8biIv62uXS4zxgGqGOUBdkDmvFZzq4kAlw38lx8bLkZxDqJ\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   116
        "sS+xFQIDAQABAkByx/5Oo2hQ/w2q4L8z+NTRlJ3vdl8iIDtC/4XPnfYfnGptnpG6\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   117
        "ZThQRvbMZiai0xHQPQMszvAHjZVme1eDl3EBAiEA3aKJHynPVCEJhpfCLWuMwX5J\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   118
        "1LntwJO7NTOyU5m8rPECIQDTpzn5X44r2rzWBDna/Sx7HW9IWCxNgUD2Eyi2nA7W\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   119
        "ZQIgJerEorw4aCAuzQPxiGu57PB6GRamAihEAtoRTBQlH0ECIQDN08FgTtnesgCU\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   120
        "DFYLLcw1CiHvc7fZw4neBDHCrC8NtQIgA8TOUkGnpCZlQ0KaI8KfKWI+vxFcgFnH\n" +
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   121
        "3fnqsTgaUs4=";
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   122
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   123
    static char passphrase[] = "passphrase".toCharArray();
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   124
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   125
    /*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   126
     * Is the server ready to serve?
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   127
     */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   128
    volatile static boolean serverReady = false;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   129
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   130
    /*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   131
     * Turn on SSL debugging?
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   132
     */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   133
    static boolean debug = false;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   134
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   135
    /*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   136
     * Define the server side of the test.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   137
     *
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   138
     * If the server prematurely exits, serverReady will be set to true
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   139
     * to avoid infinite hangs.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   140
     */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   141
    void doServerSide() throws Exception {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   142
        SSLContext context = generateSSLContext(null, targetCertStr,
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   143
                                            targetPrivateKey);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   144
        SSLServerSocketFactory sslssf = context.getServerSocketFactory();
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   145
        SSLServerSocket sslServerSocket =
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   146
            (SSLServerSocket)sslssf.createServerSocket(serverPort);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   147
        serverPort = sslServerSocket.getLocalPort();
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   148
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   149
        /*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   150
         * Signal Client, we're ready for his connect.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   151
         */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   152
        serverReady = true;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   153
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   154
        try (SSLSocket sslSocket = (SSLSocket)sslServerSocket.accept()) {
21658
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   155
            try (InputStream sslIS = sslSocket.getInputStream()) {
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   156
                sslIS.read();
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   157
            }
14929
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   158
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   159
            throw new Exception(
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   160
                    "RSA keys shorter than 1024 bits should be disabled");
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   161
        } catch (SSLHandshakeException sslhe) {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   162
            // the expected exception, ignore
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   163
        }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   164
    }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   165
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   166
    /*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   167
     * Define the client side of the test.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   168
     *
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   169
     * If the server prematurely exits, serverReady will be set to true
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   170
     * to avoid infinite hangs.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   171
     */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   172
    void doClientSide() throws Exception {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   173
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   174
        /*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   175
         * Wait for server to get started.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   176
         */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   177
        while (!serverReady) {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   178
            Thread.sleep(50);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   179
        }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   180
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   181
        SSLContext context = generateSSLContext(trustedCertStr, null, null);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   182
        SSLSocketFactory sslsf = context.getSocketFactory();
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   183
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   184
        try (SSLSocket sslSocket =
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   185
            (SSLSocket)sslsf.createSocket("localhost", serverPort)) {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   186
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   187
            // only enable the target protocol
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   188
            sslSocket.setEnabledProtocols(new String[] {enabledProtocol});
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   189
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   190
            // enable a block cipher
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   191
            sslSocket.setEnabledCipherSuites(
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   192
                new String[] {"TLS_DHE_RSA_WITH_AES_128_CBC_SHA"});
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   193
21658
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   194
            try (OutputStream sslOS = sslSocket.getOutputStream()) {
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   195
                sslOS.write('B');
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   196
                sslOS.flush();
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   197
            }
14929
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   198
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   199
            throw new Exception(
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   200
                    "RSA keys shorter than 1024 bits should be disabled");
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   201
        } catch (SSLHandshakeException sslhe) {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   202
            // the expected exception, ignore
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   203
        }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   204
    }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   205
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   206
    /*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   207
     * =============================================================
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   208
     * The remainder is just support stuff
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   209
     */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   210
    private static String tmAlgorithm;        // trust manager
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   211
    private static String enabledProtocol;    // the target protocol
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   212
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   213
    private static void parseArguments(String[] args) {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   214
        tmAlgorithm = args[0];
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   215
        enabledProtocol = args[1];
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   216
    }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   217
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   218
    private static SSLContext generateSSLContext(String trustedCertStr,
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   219
            String keyCertStr, String keySpecStr) throws Exception {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   220
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   221
        // generate certificate from cert string
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   222
        CertificateFactory cf = CertificateFactory.getInstance("X.509");
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   223
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   224
        // create a key store
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   225
        KeyStore ks = KeyStore.getInstance("JKS");
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   226
        ks.load(null, null);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   227
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   228
        // import the trused cert
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   229
        Certificate trusedCert = null;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   230
        ByteArrayInputStream is = null;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   231
        if (trustedCertStr != null) {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   232
            is = new ByteArrayInputStream(trustedCertStr.getBytes());
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   233
            trusedCert = cf.generateCertificate(is);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   234
            is.close();
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   235
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   236
            ks.setCertificateEntry("RSA Export Signer", trusedCert);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   237
        }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   238
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   239
        if (keyCertStr != null) {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   240
            // generate the private key.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   241
            PKCS8EncodedKeySpec priKeySpec = new PKCS8EncodedKeySpec(
16020
b57c48f16179 8006182: cleanup to use java.util.Base64 in java security component, providers, and regression tests
msheppar
parents: 14929
diff changeset
   242
                                Base64.getMimeDecoder().decode(keySpecStr));
14929
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   243
            KeyFactory kf = KeyFactory.getInstance("RSA");
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   244
            RSAPrivateKey priKey =
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   245
                    (RSAPrivateKey)kf.generatePrivate(priKeySpec);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   246
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   247
            // generate certificate chain
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   248
            is = new ByteArrayInputStream(keyCertStr.getBytes());
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   249
            Certificate keyCert = cf.generateCertificate(is);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   250
            is.close();
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   251
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   252
            Certificate[] chain = null;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   253
            if (trusedCert != null) {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   254
                chain = new Certificate[2];
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   255
                chain[0] = keyCert;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   256
                chain[1] = trusedCert;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   257
            } else {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   258
                chain = new Certificate[1];
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   259
                chain[0] = keyCert;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   260
            }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   261
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   262
            // import the key entry.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   263
            ks.setKeyEntry("Whatever", priKey, passphrase, chain);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   264
        }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   265
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   266
        // create SSL context
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   267
        TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmAlgorithm);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   268
        tmf.init(ks);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   269
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   270
        SSLContext ctx = SSLContext.getInstance("TLS");
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   271
        if (keyCertStr != null && !keyCertStr.isEmpty()) {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   272
            KeyManagerFactory kmf = KeyManagerFactory.getInstance("NewSunX509");
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   273
            kmf.init(ks, passphrase);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   274
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   275
            ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   276
            ks = null;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   277
        } else {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   278
            ctx.init(null, tmf.getTrustManagers(), null);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   279
        }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   280
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   281
        return ctx;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   282
    }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   283
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   284
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   285
    // use any free port by default
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   286
    volatile int serverPort = 0;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   287
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   288
    volatile Exception serverException = null;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   289
    volatile Exception clientException = null;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   290
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   291
    public static void main(String[] args) throws Exception {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   292
        if (debug)
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   293
            System.setProperty("javax.net.debug", "all");
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   294
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   295
        /*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   296
         * Get the customized arguments.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   297
         */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   298
        parseArguments(args);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   299
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   300
        /*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   301
         * Start the tests.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   302
         */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   303
        new DisabledShortRSAKeys();
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   304
    }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   305
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   306
    Thread clientThread = null;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   307
    Thread serverThread = null;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   308
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   309
    /*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   310
     * Primary constructor, used to drive remainder of the test.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   311
     *
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   312
     * Fork off the other side, then do your work.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   313
     */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   314
    DisabledShortRSAKeys() throws Exception {
21658
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   315
        Exception startException = null;
14929
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   316
        try {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   317
            if (separateServerThread) {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   318
                startServer(true);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   319
                startClient(false);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   320
            } else {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   321
                startClient(true);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   322
                startServer(false);
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   323
            }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   324
        } catch (Exception e) {
21658
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   325
            startException = e;
14929
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   326
        }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   327
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   328
        /*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   329
         * Wait for other side to close down.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   330
         */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   331
        if (separateServerThread) {
21658
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   332
            if (serverThread != null) {
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   333
                serverThread.join();
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   334
            }
14929
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   335
        } else {
21658
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   336
            if (clientThread != null) {
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   337
                clientThread.join();
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   338
            }
14929
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   339
        }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   340
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   341
        /*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   342
         * When we get here, the test is pretty much over.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   343
         * Which side threw the error?
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   344
         */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   345
        Exception local;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   346
        Exception remote;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   347
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   348
        if (separateServerThread) {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   349
            remote = serverException;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   350
            local = clientException;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   351
        } else {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   352
            remote = clientException;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   353
            local = serverException;
21658
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   354
        }
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   355
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   356
        Exception exception = null;
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   357
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   358
        /*
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   359
         * Check various exception conditions.
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   360
         */
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   361
        if ((local != null) && (remote != null)) {
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   362
            // If both failed, return the curthread's exception.
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   363
            local.initCause(remote);
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   364
            exception = local;
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   365
        } else if (local != null) {
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   366
            exception = local;
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   367
        } else if (remote != null) {
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   368
            exception = remote;
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   369
        } else if (startException != null) {
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   370
            exception = startException;
14929
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   371
        }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   372
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   373
        /*
21658
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   374
         * If there was an exception *AND* a startException,
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   375
         * output it.
14929
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   376
         */
21658
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   377
        if (exception != null) {
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   378
            if (exception != startException && startException != null) {
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   379
                exception.addSuppressed(startException);
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   380
            }
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   381
            throw exception;
14929
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   382
        }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   383
21658
3a2a0734cb71 8023147: Test DisabledShortRSAKeys.java intermittent failed
xuelei
parents: 16020
diff changeset
   384
        // Fall-through: no exception to throw!
14929
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   385
    }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   386
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   387
    void startServer(boolean newThread) throws Exception {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   388
        if (newThread) {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   389
            serverThread = new Thread() {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   390
                public void run() {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   391
                    try {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   392
                        doServerSide();
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   393
                    } catch (Exception e) {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   394
                        /*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   395
                         * Our server thread just died.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   396
                         *
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   397
                         * Release the client, if not active already...
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   398
                         */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   399
                        System.err.println("Server died...");
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   400
                        serverReady = true;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   401
                        serverException = e;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   402
                    }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   403
                }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   404
            };
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   405
            serverThread.start();
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   406
        } else {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   407
            try {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   408
                doServerSide();
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   409
            } catch (Exception e) {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   410
                serverException = e;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   411
            } finally {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   412
                serverReady = true;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   413
            }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   414
        }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   415
    }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   416
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   417
    void startClient(boolean newThread) throws Exception {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   418
        if (newThread) {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   419
            clientThread = new Thread() {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   420
                public void run() {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   421
                    try {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   422
                        doClientSide();
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   423
                    } catch (Exception e) {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   424
                        /*
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   425
                         * Our client thread just died.
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   426
                         */
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   427
                        System.err.println("Client died...");
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   428
                        clientException = e;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   429
                    }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   430
                }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   431
            };
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   432
            clientThread.start();
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   433
        } else {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   434
            try {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   435
                doClientSide();
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   436
            } catch (Exception e) {
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   437
                clientException = e;
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   438
            }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   439
        }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   440
    }
59377f4b9919 7109274: Restrict the use of certificates with RSA keys less than 1024 bits
xuelei
parents:
diff changeset
   441
}