1e82be46881b2ab9d64b35c0ee53fc359b5cfd18aNarayan Kamathpackage org.apache.harmony.tests.javax.net.ssl;
2adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
3051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumannimport java.io.ByteArrayInputStream;
4051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumannimport java.net.Socket;
51cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grobimport java.security.KeyFactory;
61cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grobimport java.security.KeyStore;
71cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grobimport java.security.NoSuchAlgorithmException;
8adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectimport java.security.PrivateKey;
91cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grobimport java.security.cert.CertificateFactory;
101cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grobimport java.security.cert.X509Certificate;
11051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumannimport java.security.spec.PKCS8EncodedKeySpec;
12051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumannimport javax.net.ssl.KeyManagerFactory;
13051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumannimport javax.net.ssl.X509KeyManager;
14adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectimport junit.framework.TestCase;
15adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
16adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project/**
17adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * Tests for <code>X509KeyManager</code> class constructors and methods.
18adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project */
19adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectpublic class X509KeyManagerTest extends TestCase {
20f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
211cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob    private X509KeyManager manager;
221cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob    private KeyManagerFactory factory;
23f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
248272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom    private static final String CLIENT = "CLIENT";
258272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom    private static final String SERVER = "SERVER";
268272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom    private static final String TYPE_RSA = "RSA";
278272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom    private static final char[] PASSWORD = "1234".toCharArray();
288272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom
291cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob    private String keyType;
301cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob    private KeyStore keyTest;
318272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom    private X509Certificate[] cert;
328272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom    private PrivateKey[] keys;
331cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob
34f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
35be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob    /*
361cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob       Certificate:
371cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob           Data:
381cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Version: 3 (0x2)
391cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Serial Number: 0 (0x0)
401cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Signature Algorithm: sha1WithRSAEncryption
411cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Issuer: C=AN, ST=Android, O=Android, OU=Android, CN=Android/emailAddress=android@android.com
421cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Validity
431cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                   Not Before: Mar 20 17:00:06 2009 GMT
441cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                   Not After : Mar 19 17:00:06 2012 GMT
451cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Subject: C=AN, ST=Android, O=Android, OU=Android, CN=Android/emailAddress=android@android.com
461cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Subject Public Key Info:
471cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                   Public Key Algorithm: rsaEncryption
481cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                   RSA Public Key: (1024 bit)
491cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       Modulus (1024 bit):
501cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           00:aa:42:40:ed:92:21:17:99:5f:0e:e4:42:b8:cb:
511cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           66:3d:63:2a:16:34:3c:7b:d3:3e:1f:a8:3f:bd:9a:
521cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           eb:b3:24:6b:8c:e4:da:2f:31:bc:61:07:27:2e:28:
531cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           71:77:58:ae:b4:89:7c:eb:b0:06:24:07:57:3c:54:
541cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           71:db:71:41:05:ab:3d:9f:05:d2:ca:cb:1c:bf:9d:
551cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           8a:21:96:8f:13:61:25:69:12:3b:77:bd:f7:34:b2:
561cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           09:a9:e0:52:94:44:31:ce:db:3d:eb:64:f1:d6:ca:
571cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           c5:7d:2f:d6:6f:8d:e4:29:8b:06:98:8a:95:3d:7a:
581cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           97:41:9a:f1:66:c5:09:82:0d
591cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       Exponent: 65537 (0x10001)
601cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               X509v3 extensions:
61f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes                   X509v3 Subject Key Identifier:
621cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       E7:9B:7D:90:29:EA:90:0B:7F:08:41:76:4E:41:23:E8:43:2C:A9:03
63f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes                   X509v3 Authority Key Identifier:
641cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       keyid:E7:9B:7D:90:29:EA:90:0B:7F:08:41:76:4E:41:23:E8:43:2C:A9:03
651cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       DirName:/C=AN/ST=Android/O=Android/OU=Android/CN=Android/emailAddress=android@android.com
661cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       serial:00
67be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob
68f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes                   X509v3 Basic Constraints:
691cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       CA:TRUE
701cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob           Signature Algorithm: sha1WithRSAEncryption
711cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               14:98:30:29:42:ef:ab:e6:b8:25:4b:55:85:04:a5:c4:dd:1d:
721cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               8b:6a:c1:6f:6c:1c:1d:c3:61:34:30:07:34:4d:6a:8b:55:6f:
731cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               75:55:6e:15:58:c5:f8:af:e0:be:73:ba:d9:a5:85:d7:b5:1a:
741cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               85:44:2b:88:fd:cc:cb:d1:ed:46:69:43:ff:59:ae:9b:5c:17:
751cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               26:da:ee:c8:bf:67:55:01:a0:0e:10:b9:85:49:54:d9:79:1e:
761cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               7b:2e:6f:65:4f:d9:10:2e:9d:b8:92:63:67:74:8b:22:0d:6d:
771cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               d3:5d:9e:29:63:f9:36:93:1b:a7:80:e2:b1:f1:bf:29:19:81:
781cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               3d:07
79be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     */
80be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob    String certificate = "-----BEGIN CERTIFICATE-----\n"
81be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "MIIDPzCCAqigAwIBAgIBADANBgkqhkiG9w0BAQUFADB5MQswCQYDVQQGEwJBTjEQ\n"
82be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "MA4GA1UECBMHQW5kcm9pZDEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5k\n"
83be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "cm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBh\n"
84be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "bmRyb2lkLmNvbTAeFw0wOTAzMjAxNzAwMDZaFw0xMjAzMTkxNzAwMDZaMHkxCzAJ\n"
85be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "BgNVBAYTAkFOMRAwDgYDVQQIEwdBbmRyb2lkMRAwDgYDVQQKEwdBbmRyb2lkMRAw\n"
86be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "DgYDVQQLEwdBbmRyb2lkMRAwDgYDVQQDEwdBbmRyb2lkMSIwIAYJKoZIhvcNAQkB\n"
87be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "FhNhbmRyb2lkQGFuZHJvaWQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB\n"
88be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "gQCqQkDtkiEXmV8O5EK4y2Y9YyoWNDx70z4fqD+9muuzJGuM5NovMbxhBycuKHF3\n"
89be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "WK60iXzrsAYkB1c8VHHbcUEFqz2fBdLKyxy/nYohlo8TYSVpEjt3vfc0sgmp4FKU\n"
90be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "RDHO2z3rZPHWysV9L9ZvjeQpiwaYipU9epdBmvFmxQmCDQIDAQABo4HWMIHTMB0G\n"
91be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "A1UdDgQWBBTnm32QKeqQC38IQXZOQSPoQyypAzCBowYDVR0jBIGbMIGYgBTnm32Q\n"
92be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "KeqQC38IQXZOQSPoQyypA6F9pHsweTELMAkGA1UEBhMCQU4xEDAOBgNVBAgTB0Fu\n"
93be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "ZHJvaWQxEDAOBgNVBAoTB0FuZHJvaWQxEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNV\n"
94be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "BAMTB0FuZHJvaWQxIjAgBgkqhkiG9w0BCQEWE2FuZHJvaWRAYW5kcm9pZC5jb22C\n"
95be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "AQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQAUmDApQu+r5rglS1WF\n"
96be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "BKXE3R2LasFvbBwdw2E0MAc0TWqLVW91VW4VWMX4r+C+c7rZpYXXtRqFRCuI/czL\n"
97be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "0e1GaUP/Wa6bXBcm2u7Iv2dVAaAOELmFSVTZeR57Lm9lT9kQLp24kmNndIsiDW3T\n"
98be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "XZ4pY/k2kxungOKx8b8pGYE9Bw==\n"
99be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "-----END CERTIFICATE-----";
1001cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob
101be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob    ByteArrayInputStream certArray = new ByteArrayInputStream(certificate
102be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            .getBytes());
103be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob
104be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob    /*
105be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * The key in DER format.
106f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     * Below is the same key in PEM format as reference
107be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     */
108be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob    byte[] keyBytes = new byte[] {
109051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x30, (byte)0x82, (byte)0x02, (byte)0x77, (byte)0x02, (byte)0x01, (byte)0x00,
110051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x30, (byte)0x0d, (byte)0x06, (byte)0x09, (byte)0x2a, (byte)0x86, (byte)0x48,
111051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x86, (byte)0xf7, (byte)0x0d, (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x05,
112051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x00, (byte)0x04, (byte)0x82, (byte)0x02, (byte)0x61, (byte)0x30, (byte)0x82,
113051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x02, (byte)0x5d, (byte)0x02, (byte)0x01, (byte)0x00, (byte)0x02, (byte)0x81,
114051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x81, (byte)0x00, (byte)0xaa, (byte)0x42, (byte)0x40, (byte)0xed, (byte)0x92,
115051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x21, (byte)0x17, (byte)0x99, (byte)0x5f, (byte)0x0e, (byte)0xe4, (byte)0x42,
116051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xb8, (byte)0xcb, (byte)0x66, (byte)0x3d, (byte)0x63, (byte)0x2a, (byte)0x16,
117051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x34, (byte)0x3c, (byte)0x7b, (byte)0xd3, (byte)0x3e, (byte)0x1f, (byte)0xa8,
118051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x3f, (byte)0xbd, (byte)0x9a, (byte)0xeb, (byte)0xb3, (byte)0x24, (byte)0x6b,
119051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x8c, (byte)0xe4, (byte)0xda, (byte)0x2f, (byte)0x31, (byte)0xbc, (byte)0x61,
120051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x07, (byte)0x27, (byte)0x2e, (byte)0x28, (byte)0x71, (byte)0x77, (byte)0x58,
121051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xae, (byte)0xb4, (byte)0x89, (byte)0x7c, (byte)0xeb, (byte)0xb0, (byte)0x06,
122051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x24, (byte)0x07, (byte)0x57, (byte)0x3c, (byte)0x54, (byte)0x71, (byte)0xdb,
123051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x71, (byte)0x41, (byte)0x05, (byte)0xab, (byte)0x3d, (byte)0x9f, (byte)0x05,
124051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xd2, (byte)0xca, (byte)0xcb, (byte)0x1c, (byte)0xbf, (byte)0x9d, (byte)0x8a,
125051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x21, (byte)0x96, (byte)0x8f, (byte)0x13, (byte)0x61, (byte)0x25, (byte)0x69,
126051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x12, (byte)0x3b, (byte)0x77, (byte)0xbd, (byte)0xf7, (byte)0x34, (byte)0xb2,
127051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x09, (byte)0xa9, (byte)0xe0, (byte)0x52, (byte)0x94, (byte)0x44, (byte)0x31,
128051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xce, (byte)0xdb, (byte)0x3d, (byte)0xeb, (byte)0x64, (byte)0xf1, (byte)0xd6,
129051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xca, (byte)0xc5, (byte)0x7d, (byte)0x2f, (byte)0xd6, (byte)0x6f, (byte)0x8d,
130051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xe4, (byte)0x29, (byte)0x8b, (byte)0x06, (byte)0x98, (byte)0x8a, (byte)0x95,
131051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x3d, (byte)0x7a, (byte)0x97, (byte)0x41, (byte)0x9a, (byte)0xf1, (byte)0x66,
132051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xc5, (byte)0x09, (byte)0x82, (byte)0x0d, (byte)0x02, (byte)0x03, (byte)0x01,
133051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x81, (byte)0x80, (byte)0x34, (byte)0x91,
134051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x8e, (byte)0x50, (byte)0x8b, (byte)0xfc, (byte)0xf1, (byte)0xb7, (byte)0x66,
135051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x35, (byte)0x47, (byte)0xdf, (byte)0x1e, (byte)0x05, (byte)0x97, (byte)0x44,
136051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xbe, (byte)0xf8, (byte)0x80, (byte)0xb0, (byte)0x92, (byte)0x38, (byte)0x3d,
137051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x4a, (byte)0x02, (byte)0x26, (byte)0x45, (byte)0xbf, (byte)0xfa, (byte)0x34,
138051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x6a, (byte)0x34, (byte)0x85, (byte)0x8c, (byte)0x94, (byte)0x20, (byte)0x95,
139051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xcf, (byte)0xca, (byte)0x75, (byte)0x3e, (byte)0xeb, (byte)0x27, (byte)0x02,
140051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x4f, (byte)0xbe, (byte)0x64, (byte)0xc0, (byte)0x54, (byte)0x77, (byte)0xda,
141051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xfd, (byte)0x3e, (byte)0x75, (byte)0x36, (byte)0xec, (byte)0x99, (byte)0x4f,
142051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xc4, (byte)0x56, (byte)0xff, (byte)0x45, (byte)0x61, (byte)0xa8, (byte)0xa8,
143051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x41, (byte)0xe4, (byte)0x42, (byte)0x71, (byte)0x7a, (byte)0x8c, (byte)0x84,
144051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xc2, (byte)0x02, (byte)0x40, (byte)0x0b, (byte)0x3d, (byte)0x42, (byte)0xe0,
145051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x8b, (byte)0x22, (byte)0xf7, (byte)0x4c, (byte)0xa3, (byte)0xbb, (byte)0xd8,
146051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x8f, (byte)0x45, (byte)0xa2, (byte)0x55, (byte)0xc7, (byte)0xd0, (byte)0x6a,
147051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x25, (byte)0xbf, (byte)0xda, (byte)0x54, (byte)0x57, (byte)0x14, (byte)0x91,
148051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x0c, (byte)0x09, (byte)0x0b, (byte)0x9a, (byte)0x50, (byte)0xca, (byte)0xe6,
149051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x9e, (byte)0x28, (byte)0xc3, (byte)0x78, (byte)0x39, (byte)0x10, (byte)0x06,
150051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x02, (byte)0x96, (byte)0x10, (byte)0x1a, (byte)0xd2, (byte)0x4b, (byte)0x7b,
151051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x6c, (byte)0x72, (byte)0x9e, (byte)0x1e, (byte)0xac, (byte)0xd2, (byte)0xc1,
152051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x02, (byte)0x41, (byte)0x00, (byte)0xde, (byte)0x27, (byte)0xbd, (byte)0x43,
153051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xa4, (byte)0xbd, (byte)0x95, (byte)0x14, (byte)0x2e, (byte)0x1c, (byte)0xa0,
154051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x74, (byte)0xa5, (byte)0x3e, (byte)0xfa, (byte)0xf9, (byte)0x15, (byte)0xb2,
155051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x29, (byte)0x6a, (byte)0x2a, (byte)0x42, (byte)0x94, (byte)0x5a, (byte)0xf2,
156051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x81, (byte)0xf3, (byte)0xe1, (byte)0x76, (byte)0x49, (byte)0x11, (byte)0x9d,
157051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x18, (byte)0xc5, (byte)0xeb, (byte)0xb6, (byte)0xbc, (byte)0x81, (byte)0x3a,
158051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x14, (byte)0x9c, (byte)0x41, (byte)0x01, (byte)0x58, (byte)0x56, (byte)0xa9,
159051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x9b, (byte)0x73, (byte)0x2f, (byte)0xd9, (byte)0xa8, (byte)0x8e, (byte)0xc4,
160051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x48, (byte)0x69, (byte)0x35, (byte)0xe6, (byte)0xf4, (byte)0x73, (byte)0x2f,
161051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xf9, (byte)0x12, (byte)0x12, (byte)0x71, (byte)0x02, (byte)0x41, (byte)0x00,
162051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xc4, (byte)0x32, (byte)0x81, (byte)0x5d, (byte)0x19, (byte)0x54, (byte)0x2c,
163051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x29, (byte)0x5a, (byte)0x9f, (byte)0x36, (byte)0x4c, (byte)0x6f, (byte)0x2d,
164051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xfd, (byte)0x62, (byte)0x0e, (byte)0xe6, (byte)0x37, (byte)0xc2, (byte)0xf6,
165051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x69, (byte)0x64, (byte)0xf9, (byte)0x3a, (byte)0xcc, (byte)0xb2, (byte)0x63,
166051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x2f, (byte)0xa9, (byte)0xfe, (byte)0x7e, (byte)0x8b, (byte)0x2d, (byte)0x69,
167051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x13, (byte)0xe5, (byte)0x61, (byte)0x58, (byte)0xb7, (byte)0xfa, (byte)0x55,
168051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x74, (byte)0x2c, (byte)0xe8, (byte)0xa1, (byte)0xac, (byte)0xc3, (byte)0xdd,
169051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x5b, (byte)0x62, (byte)0xae, (byte)0x0a, (byte)0x27, (byte)0xce, (byte)0xb0,
170051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xf2, (byte)0x81, (byte)0x5f, (byte)0x9a, (byte)0x6f, (byte)0x5f, (byte)0x3f,
171051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x5d, (byte)0x02, (byte)0x41, (byte)0x00, (byte)0x92, (byte)0x42, (byte)0xff,
172051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xac, (byte)0xe5, (byte)0x6d, (byte)0x9c, (byte)0x15, (byte)0x29, (byte)0x36,
173051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xd7, (byte)0xbd, (byte)0x74, (byte)0x7e, (byte)0x3e, (byte)0xa6, (byte)0x77,
174051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xce, (byte)0x50, (byte)0xce, (byte)0x00, (byte)0xfc, (byte)0xcc, (byte)0xc8,
175051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x04, (byte)0x19, (byte)0xe3, (byte)0x03, (byte)0x71, (byte)0xe9, (byte)0x31,
176051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x9b, (byte)0x88, (byte)0x8f, (byte)0xe6, (byte)0x5c, (byte)0xed, (byte)0x46,
177051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xf7, (byte)0x82, (byte)0x52, (byte)0x4d, (byte)0xca, (byte)0x20, (byte)0xeb,
178051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x0d, (byte)0xc7, (byte)0xb6, (byte)0xd2, (byte)0xae, (byte)0x2e, (byte)0xf7,
179051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xaf, (byte)0xeb, (byte)0x2c, (byte)0xb9, (byte)0xbc, (byte)0x50, (byte)0xfc,
180051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xf5, (byte)0x7c, (byte)0xba, (byte)0x95, (byte)0x41, (byte)0x02, (byte)0x40,
181051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x54, (byte)0xf8, (byte)0x46, (byte)0x9c, (byte)0x6a, (byte)0x5e, (byte)0xd0,
182051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xed, (byte)0x6c, (byte)0x08, (byte)0xed, (byte)0xfc, (byte)0x36, (byte)0x5e,
183051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x65, (byte)0x91, (byte)0x75, (byte)0x40, (byte)0x71, (byte)0x3f, (byte)0xe7,
184051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x76, (byte)0x07, (byte)0xbc, (byte)0x04, (byte)0xa2, (byte)0x28, (byte)0x53,
185051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xda, (byte)0x8d, (byte)0xb5, (byte)0xe1, (byte)0x5a, (byte)0x27, (byte)0x65,
186051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x8d, (byte)0xaf, (byte)0x56, (byte)0xf4, (byte)0x94, (byte)0x61, (byte)0x3f,
187051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x67, (byte)0x1c, (byte)0x17, (byte)0xf8, (byte)0x05, (byte)0x19, (byte)0xa2,
188051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xa1, (byte)0x74, (byte)0x60, (byte)0x49, (byte)0x97, (byte)0xa9, (byte)0xe5,
189051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x6a, (byte)0x71, (byte)0x6b, (byte)0x55, (byte)0x38, (byte)0x0c, (byte)0xb9,
190051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x25, (byte)0x02, (byte)0x41, (byte)0x00, (byte)0xae, (byte)0xf2, (byte)0xa8,
191051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x6d, (byte)0x1d, (byte)0x35, (byte)0x38, (byte)0x73, (byte)0x98, (byte)0x15,
192051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xc7, (byte)0x15, (byte)0x02, (byte)0x2f, (byte)0x29, (byte)0x5d, (byte)0x18,
193051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x4b, (byte)0x7d, (byte)0xb2, (byte)0x59, (byte)0xbe, (byte)0x5a, (byte)0xc7,
194051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x72, (byte)0xd0, (byte)0x80, (byte)0xd8, (byte)0x77, (byte)0xa1, (byte)0x7f,
195051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xb2, (byte)0x35, (byte)0x0d, (byte)0x78, (byte)0x92, (byte)0x91, (byte)0x35,
196051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x47, (byte)0xeb, (byte)0x4b, (byte)0x00, (byte)0x59, (byte)0xb4, (byte)0xc4,
197051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x2c, (byte)0x29, (byte)0xe7, (byte)0x39, (byte)0x9d, (byte)0x48, (byte)0x8b,
198051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x4f, (byte)0x46, (byte)0xe6, (byte)0xce, (byte)0xd3, (byte)0x6c, (byte)0x84,
199051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x9b, (byte)0xd2, (byte)0x10, (byte)0xb0, (byte)0xe1
200051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann    };
201f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
202be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob    /*
203be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * The same key in PEM format.
204be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * The DER version of this key was created using
205f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
206be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * openssl pkcs8 -topk8 -nocrypt -in key1.pem
207be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     *         -inform PEM -out key1.der -outform DER
208f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
209be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * -----BEGIN RSA PRIVATE KEY-----
210be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * Proc-Type: 4,ENCRYPTED
211be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * DEK-Info: DES-EDE3-CBC,69E26FCC3A7F136E
212f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
213be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * YKiLXOwf2teog4IoOvbbROy9vqp0EMt1KF9eNKeKFCWGCS4RFATaAGjKrdA26bOV
214be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * MBdyB4V7qaxLC8/UwLlzFLpprouIfGqrEoR/NT0eKQ+4Pl25GlMvlPaR0pATBLZ2
215be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * OEaB3zcNygOQ02Jdrmw2+CS9qVtGGXjn6Qp6TVFm6edNCoOVZODLP9kkzPLn8Mkm
216be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * /isgsprwMELuth8Y5BC0brI5XYdMqZFI5dLz4wzVH81wBYbRmJqR7yOE1pzAJS9I
217be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * gJ5YvcP7pSmoA2SHVN4v4qolM+GAM9YIp2bwEyWFRjbriNlF1yM+HflGMEZ1HNpZ
218be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * FSFFA3G8EIH9ogbZ3j+7EujrndJC7GIibwiu5rd3eIHtcwrWprp+wEoPc/vM8OpR
219be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * so9ms7iQYV6faYCWK4yeCfErYw7t+AhGqfLiqHO6bO2XAYJcD28RYV9gXmugZOhT
220be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * 9471MOw94HWF5tBVjgIkyNBcbRyMF9iyQKafbkHYpmxaB4s2EqQr1SNZl3SLEwhX
221be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * MEGy3/tyveuMLAvdTlSDZbt6memWoXXEX4Ep/q6r0ErCTY31awdP/XaJcJBGb9ni
222be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * Iai8DICaG1v4bUuBVgaiacZlgw1O4Hhj8D2DWfVZsgpx5y8tBRM2lGWvyzEi5n2F
223be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * PiR2UlT0DjCD1ObjCpWJ5insX/w8dXSHGZLLb9ccGRUrw/+5Bptn+AoEfdP+8S3j
224be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * UdMdxl6qt2gneCYu1Lr3cQ+qKPqikQty2UQ6Yp8dJkheLJ2Tr+rnaytOCp2dAT9K
225be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * KXTimIcXV+ftvUMbDPXYu4LJBldr2VokD+k3QbHDgFnfHIiNkwiPzA==
226be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * -----END RSA PRIVATE KEY-----
227be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     */
2281cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob
229be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob    /*
2301cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob       Certificate:
2311cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob           Data:
2321cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Version: 3 (0x2)
2331cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Serial Number: 1 (0x1)
2341cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Signature Algorithm: sha1WithRSAEncryption
2351cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Issuer: C=AN, ST=Android, O=Android, OU=Android, CN=Android/emailAddress=android@android.com
2361cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Validity
2371cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                   Not Before: Mar 20 17:00:40 2009 GMT
2381cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                   Not After : Mar 20 17:00:40 2010 GMT
2391cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Subject: C=AN, ST=Android, L=Android, O=Android, OU=Android, CN=Android/emailAddress=android@android.com
2401cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Subject Public Key Info:
2411cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                   Public Key Algorithm: rsaEncryption
2421cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                   RSA Public Key: (1024 bit)
2431cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       Modulus (1024 bit):
2441cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           00:d0:44:5a:c4:76:ef:ae:ff:99:5b:c3:37:c1:09:
2451cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           33:c1:97:e5:64:7a:a9:7e:98:4b:3a:a3:33:d0:5c:
2461cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           c7:56:ac:d8:42:e8:4a:ac:9c:d9:8f:89:84:c8:46:
2471cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           95:ce:22:f7:6a:09:de:91:47:9c:38:23:a5:4a:fc:
2481cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           08:af:5a:b4:6e:39:8e:e9:f5:0e:46:00:69:e1:e5:
2491cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           cc:4c:81:b6:82:7b:56:fb:f4:dc:04:ff:61:e2:7e:
2501cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           5f:e2:f9:97:53:93:d4:69:9b:ba:79:20:cd:1e:3e:
2511cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           d5:9a:44:95:7c:cf:c1:51:f2:22:fc:ec:cc:66:18:
2521cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           74:60:2a:a2:be:06:c2:9e:8d
2531cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       Exponent: 65537 (0x10001)
2541cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               X509v3 extensions:
255f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes                   X509v3 Basic Constraints:
2561cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       CA:FALSE
257f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes                   Netscape Comment:
2581cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       OpenSSL Generated Certificate
259f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes                   X509v3 Subject Key Identifier:
2601cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       95:3E:C3:46:69:52:78:08:05:46:B9:00:69:E5:E7:A7:99:E3:C4:67
261f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes                   X509v3 Authority Key Identifier:
2621cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       keyid:E7:9B:7D:90:29:EA:90:0B:7F:08:41:76:4E:41:23:E8:43:2C:A9:03
263be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob
2641cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob           Signature Algorithm: sha1WithRSAEncryption
2651cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               a3:5b:30:f5:28:3f:87:f6:1b:36:6a:22:6d:66:48:fa:cb:ee:
2661cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               4c:04:cf:11:14:e2:1f:b5:68:0c:e7:61:0e:bc:d3:69:19:02:
2671cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               8b:d5:d3:05:4a:c8:29:e8:e3:d0:e9:32:ad:6c:7d:9c:c4:46:
2681cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               6c:f9:66:e6:64:60:47:6b:ef:8e:c8:1c:67:5a:5a:cf:73:a3:
2691cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               7e:9d:6e:89:0c:67:99:17:3d:b2:b8:8e:41:95:9c:84:95:bf:
2701cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               57:95:24:22:8f:19:12:c1:fd:23:45:75:7f:4f:61:06:e3:9f:
2711cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               05:dc:e7:29:9a:6b:17:e1:e1:37:d5:8b:ba:b4:d0:8a:3c:dd:
2721cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               3f:6a
273be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     */
274be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob    String certificate2 = "-----BEGIN CERTIFICATE-----\n"
275be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "MIIC9jCCAl+gAwIBAgIBATANBgkqhkiG9w0BAQUFADB5MQswCQYDVQQGEwJBTjEQ\n"
276be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "MA4GA1UECBMHQW5kcm9pZDEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5k\n"
277be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "cm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBh\n"
278be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "bmRyb2lkLmNvbTAeFw0wOTAzMjAxNzAwNDBaFw0xMDAzMjAxNzAwNDBaMIGLMQsw\n"
279be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "CQYDVQQGEwJBTjEQMA4GA1UECBMHQW5kcm9pZDEQMA4GA1UEBxMHQW5kcm9pZDEQ\n"
280be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "MA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5k\n"
281be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "cm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCBnzANBgkq\n"
282be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "hkiG9w0BAQEFAAOBjQAwgYkCgYEA0ERaxHbvrv+ZW8M3wQkzwZflZHqpfphLOqMz\n"
283be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "0FzHVqzYQuhKrJzZj4mEyEaVziL3agnekUecOCOlSvwIr1q0bjmO6fUORgBp4eXM\n"
284be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "TIG2gntW+/TcBP9h4n5f4vmXU5PUaZu6eSDNHj7VmkSVfM/BUfIi/OzMZhh0YCqi\n"
285be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "vgbCno0CAwEAAaN7MHkwCQYDVR0TBAIwADAsBglghkgBhvhCAQ0EHxYdT3BlblNT\n"
286be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "TCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFJU+w0ZpUngIBUa5AGnl\n"
287be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "56eZ48RnMB8GA1UdIwQYMBaAFOebfZAp6pALfwhBdk5BI+hDLKkDMA0GCSqGSIb3\n"
288be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "DQEBBQUAA4GBAKNbMPUoP4f2GzZqIm1mSPrL7kwEzxEU4h+1aAznYQ6802kZAovV\n"
289be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "0wVKyCno49DpMq1sfZzERmz5ZuZkYEdr747IHGdaWs9zo36dbokMZ5kXPbK4jkGV\n"
290be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "nISVv1eVJCKPGRLB/SNFdX9PYQbjnwXc5ymaaxfh4TfVi7q00Io83T9q\n\n"
291be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            + "-----END CERTIFICATE-----";
2921cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob
293be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob    ByteArrayInputStream certArray2 = new ByteArrayInputStream(certificate2
294be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob            .getBytes());
295be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob
296be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob       /*
297be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob        * The key in DER format.
298f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes        * Below is the same key in PEM format as reference
299be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob        */
300051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann       byte[] key2Bytes = new byte[] {
301051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x30, (byte)0x82, (byte)0x02, (byte)0x75, (byte)0x02, (byte)0x01, (byte)0x00,
302051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x30, (byte)0x0d, (byte)0x06, (byte)0x09, (byte)0x2a, (byte)0x86, (byte)0x48,
303051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x86, (byte)0xf7, (byte)0x0d, (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x05,
304051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x00, (byte)0x04, (byte)0x82, (byte)0x02, (byte)0x5f, (byte)0x30, (byte)0x82,
305051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x02, (byte)0x5b, (byte)0x02, (byte)0x01, (byte)0x00, (byte)0x02, (byte)0x81,
306051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x81, (byte)0x00, (byte)0xd0, (byte)0x44, (byte)0x5a, (byte)0xc4, (byte)0x76,
307051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xef, (byte)0xae, (byte)0xff, (byte)0x99, (byte)0x5b, (byte)0xc3, (byte)0x37,
308051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xc1, (byte)0x09, (byte)0x33, (byte)0xc1, (byte)0x97, (byte)0xe5, (byte)0x64,
309051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x7a, (byte)0xa9, (byte)0x7e, (byte)0x98, (byte)0x4b, (byte)0x3a, (byte)0xa3,
310051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x33, (byte)0xd0, (byte)0x5c, (byte)0xc7, (byte)0x56, (byte)0xac, (byte)0xd8,
311051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x42, (byte)0xe8, (byte)0x4a, (byte)0xac, (byte)0x9c, (byte)0xd9, (byte)0x8f,
312051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x89, (byte)0x84, (byte)0xc8, (byte)0x46, (byte)0x95, (byte)0xce, (byte)0x22,
313051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xf7, (byte)0x6a, (byte)0x09, (byte)0xde, (byte)0x91, (byte)0x47, (byte)0x9c,
314051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x38, (byte)0x23, (byte)0xa5, (byte)0x4a, (byte)0xfc, (byte)0x08, (byte)0xaf,
315051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x5a, (byte)0xb4, (byte)0x6e, (byte)0x39, (byte)0x8e, (byte)0xe9, (byte)0xf5,
316051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x0e, (byte)0x46, (byte)0x00, (byte)0x69, (byte)0xe1, (byte)0xe5, (byte)0xcc,
317051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x4c, (byte)0x81, (byte)0xb6, (byte)0x82, (byte)0x7b, (byte)0x56, (byte)0xfb,
318051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xf4, (byte)0xdc, (byte)0x04, (byte)0xff, (byte)0x61, (byte)0xe2, (byte)0x7e,
319051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x5f, (byte)0xe2, (byte)0xf9, (byte)0x97, (byte)0x53, (byte)0x93, (byte)0xd4,
320051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x69, (byte)0x9b, (byte)0xba, (byte)0x79, (byte)0x20, (byte)0xcd, (byte)0x1e,
321051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x3e, (byte)0xd5, (byte)0x9a, (byte)0x44, (byte)0x95, (byte)0x7c, (byte)0xcf,
322051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xc1, (byte)0x51, (byte)0xf2, (byte)0x22, (byte)0xfc, (byte)0xec, (byte)0xcc,
323051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x66, (byte)0x18, (byte)0x74, (byte)0x60, (byte)0x2a, (byte)0xa2, (byte)0xbe,
324051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x06, (byte)0xc2, (byte)0x9e, (byte)0x8d, (byte)0x02, (byte)0x03, (byte)0x01,
325051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x81, (byte)0x80, (byte)0x06, (byte)0x41,
326051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xd7, (byte)0x7c, (byte)0x49, (byte)0x9a, (byte)0x7f, (byte)0xe6, (byte)0x7c,
327051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x04, (byte)0x0e, (byte)0xc4, (byte)0x71, (byte)0x0f, (byte)0x46, (byte)0xb7,
328051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xcd, (byte)0x49, (byte)0x7e, (byte)0x10, (byte)0x55, (byte)0x61, (byte)0x51,
329051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x50, (byte)0x09, (byte)0x4d, (byte)0xf7, (byte)0xf3, (byte)0x8d, (byte)0xa6,
330051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x0b, (byte)0x8b, (byte)0x9b, (byte)0xdf, (byte)0xbe, (byte)0xbc, (byte)0xe7,
331051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x9c, (byte)0xba, (byte)0xc8, (byte)0x9e, (byte)0x38, (byte)0x18, (byte)0x10,
332051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x4e, (byte)0xd5, (byte)0xe7, (byte)0xa5, (byte)0x09, (byte)0x51, (byte)0x8c,
333051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x97, (byte)0x4e, (byte)0xd0, (byte)0x79, (byte)0xbb, (byte)0x50, (byte)0x6f,
334051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x05, (byte)0x4d, (byte)0x79, (byte)0x7f, (byte)0x3f, (byte)0x26, (byte)0x76,
335051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xc1, (byte)0xcc, (byte)0x40, (byte)0x0f, (byte)0xde, (byte)0x42, (byte)0x5d,
336051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xc1, (byte)0x5f, (byte)0x70, (byte)0x46, (byte)0x70, (byte)0x8d, (byte)0xff,
337051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x26, (byte)0x35, (byte)0x75, (byte)0x9a, (byte)0x97, (byte)0xd2, (byte)0x74,
338051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x53, (byte)0x11, (byte)0x2b, (byte)0xc1, (byte)0x76, (byte)0x9c, (byte)0x9f,
339051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x93, (byte)0xaa, (byte)0xa8, (byte)0x41, (byte)0x23, (byte)0x9a, (byte)0x04,
340051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x11, (byte)0x6e, (byte)0x56, (byte)0xea, (byte)0xf5, (byte)0xd6, (byte)0x1d,
341051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x49, (byte)0x2a, (byte)0x83, (byte)0x49, (byte)0x7d, (byte)0xb7, (byte)0xd1,
342051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xe6, (byte)0x8d, (byte)0x93, (byte)0x1a, (byte)0x81, (byte)0x8e, (byte)0xc2,
343051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xb9, (byte)0xbf, (byte)0xfd, (byte)0x00, (byte)0xe2, (byte)0xb5, (byte)0x01,
344051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x02, (byte)0x41, (byte)0x00, (byte)0xea, (byte)0xce, (byte)0xc6, (byte)0x11,
345051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x1e, (byte)0xf6, (byte)0xcf, (byte)0x3a, (byte)0x8c, (byte)0xe7, (byte)0x80,
346051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x16, (byte)0x8f, (byte)0x1d, (byte)0xeb, (byte)0xa2, (byte)0xd2, (byte)0x23,
347051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x9e, (byte)0xf9, (byte)0xf1, (byte)0x14, (byte)0x16, (byte)0xc8, (byte)0x87,
348051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xf2, (byte)0x17, (byte)0xdf, (byte)0xc6, (byte)0xe4, (byte)0x1c, (byte)0x74,
349051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x74, (byte)0xb0, (byte)0xbb, (byte)0x40, (byte)0xeb, (byte)0xa6, (byte)0xb2,
350051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x5b, (byte)0x6d, (byte)0xf5, (byte)0x9a, (byte)0x85, (byte)0xf1, (byte)0x73,
351051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x84, (byte)0xec, (byte)0xdb, (byte)0x9b, (byte)0xf9, (byte)0xf8, (byte)0x3d,
352051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xba, (byte)0xeb, (byte)0xd7, (byte)0x6c, (byte)0x45, (byte)0x7b, (byte)0xca,
353051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x12, (byte)0x67, (byte)0x5f, (byte)0xcd, (byte)0x02, (byte)0x41, (byte)0x00,
354051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xe3, (byte)0x10, (byte)0x5b, (byte)0xd0, (byte)0xad, (byte)0x59, (byte)0x90,
355051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x18, (byte)0x17, (byte)0xdc, (byte)0x68, (byte)0xd4, (byte)0x75, (byte)0x55,
356051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xab, (byte)0x7d, (byte)0xd1, (byte)0xb5, (byte)0x5a, (byte)0xc4, (byte)0xb0,
357051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x2d, (byte)0xa9, (byte)0xd1, (byte)0x6f, (byte)0xe9, (byte)0x21, (byte)0x4a,
358051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x27, (byte)0xc4, (byte)0x98, (byte)0x89, (byte)0xfa, (byte)0x65, (byte)0xb6,
359051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x10, (byte)0x5d, (byte)0x66, (byte)0xdd, (byte)0x17, (byte)0xb3, (byte)0xf3,
360051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xd3, (byte)0xe3, (byte)0xa0, (byte)0x1a, (byte)0x93, (byte)0xe4, (byte)0xfb,
361051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x88, (byte)0xa7, (byte)0x3b, (byte)0x97, (byte)0x1b, (byte)0xf1, (byte)0x08,
362051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x0c, (byte)0x66, (byte)0xd0, (byte)0x86, (byte)0x5e, (byte)0x39, (byte)0xf9,
363051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xc1, (byte)0x02, (byte)0x40, (byte)0x24, (byte)0x7c, (byte)0xcd, (byte)0x3a,
364051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x8b, (byte)0xdd, (byte)0x3e, (byte)0x86, (byte)0x92, (byte)0xae, (byte)0xc6,
365051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xb0, (byte)0xba, (byte)0xbc, (byte)0xa3, (byte)0x89, (byte)0x41, (byte)0xae,
366051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x57, (byte)0x5d, (byte)0xef, (byte)0xa0, (byte)0x77, (byte)0x89, (byte)0xe1,
367051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xd6, (byte)0x34, (byte)0xef, (byte)0x89, (byte)0x30, (byte)0x99, (byte)0x5b,
368051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x5f, (byte)0x66, (byte)0xb7, (byte)0x32, (byte)0x77, (byte)0x6c, (byte)0x07,
369051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xfb, (byte)0x3d, (byte)0x33, (byte)0x15, (byte)0x38, (byte)0x0b, (byte)0x35,
370051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x30, (byte)0x4a, (byte)0xbe, (byte)0x35, (byte)0x96, (byte)0xba, (byte)0x84,
371051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x9d, (byte)0x2f, (byte)0x58, (byte)0xe2, (byte)0x72, (byte)0x49, (byte)0xb2,
372051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x34, (byte)0xf9, (byte)0xeb, (byte)0x61, (byte)0x02, (byte)0x40, (byte)0x2a,
373051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xd4, (byte)0x89, (byte)0x1d, (byte)0x21, (byte)0xb5, (byte)0xc5, (byte)0x32,
374051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x66, (byte)0x3d, (byte)0xd3, (byte)0x20, (byte)0x50, (byte)0x49, (byte)0xaa,
375051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xa1, (byte)0x7f, (byte)0x0f, (byte)0x20, (byte)0x61, (byte)0xfd, (byte)0x81,
376051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x7f, (byte)0x88, (byte)0xdb, (byte)0xfd, (byte)0x33, (byte)0xa4, (byte)0x53,
377051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x40, (byte)0x08, (byte)0x2d, (byte)0xee, (byte)0xa7, (byte)0x84, (byte)0xe2,
378051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x2d, (byte)0x5c, (byte)0x1b, (byte)0xd4, (byte)0x3e, (byte)0xc3, (byte)0x7d,
379051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x72, (byte)0x70, (byte)0x5e, (byte)0xd3, (byte)0x0a, (byte)0xdc, (byte)0x4f,
380051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x78, (byte)0x8c, (byte)0x0b, (byte)0x02, (byte)0xe0, (byte)0x42, (byte)0x4e,
381051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x64, (byte)0x8e, (byte)0x6c, (byte)0xea, (byte)0x15, (byte)0x31, (byte)0x81,
382051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x02, (byte)0x40, (byte)0x57, (byte)0x72, (byte)0xb9, (byte)0x78, (byte)0xc0,
383051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x1f, (byte)0x5b, (byte)0x1d, (byte)0xb2, (byte)0xcf, (byte)0x94, (byte)0x42,
384051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xed, (byte)0xbd, (byte)0xe7, (byte)0xaa, (byte)0x14, (byte)0x56, (byte)0xd0,
385051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x94, (byte)0x25, (byte)0x30, (byte)0x87, (byte)0x35, (byte)0x82, (byte)0xa0,
386051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x42, (byte)0xb5, (byte)0x7f, (byte)0x66, (byte)0x77, (byte)0xb0, (byte)0x13,
387051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xbe, (byte)0x57, (byte)0x06, (byte)0x7e, (byte)0x50, (byte)0x67, (byte)0x13,
388051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xa7, (byte)0x09, (byte)0xac, (byte)0xd6, (byte)0xbf, (byte)0x22, (byte)0x74,
389051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x6b, (byte)0x37, (byte)0x92, (byte)0x2b, (byte)0x91, (byte)0xbd, (byte)0x0a,
390051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xd8, (byte)0x0f, (byte)0x8d, (byte)0x86, (byte)0x4b, (byte)0x20, (byte)0x5e,
391051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x50, (byte)0x60, (byte)0x80
392051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann    };
393051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann
394be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob    /*
395be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * The same key in PEM format.
396be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * The DER version of this key was created using
397f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
398be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * openssl pkcs8 -topk8 -nocrypt -in key1.pem
399be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     *         -inform PEM -out key1.der -outform DER
400f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
401be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * -----BEGIN RSA PRIVATE KEY-----
402be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * Proc-Type: 4,ENCRYPTED
403be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * DEK-Info: DES-EDE3-CBC,370723FFDC1B1CFA
404f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
405be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * KJ20ODBEQujoOpnzNfHNoo5DF/qENhw9IaApChGMj+WhqYuFfKfPQKuRli8sJSEk
406be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * uoPmEqjJndHz5M5bI7wVxiafv/Up4+SaNKhn/vu6xjx/senJMX8HMUchqfvn0eCd
407be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * 31NHQeNbQ67O73xGIdltLzwTRsavTu/hwhnnJxiXzXnYtI5HTZUaRbVJQNpdlkNW
408be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * H91u70lwlT8W2MATBhl3R3wIbRHQG1I0RQX12O04gMfK1PBl9d/tnFOi4ESfth1W
409be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * e06XV0U12g06V5/UUuicJANvgyf0Pix0xxPr2tqibWeGpFwCvJpNHl4L3tUocydF
410be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * HYoUKx/r3VSmesnZ1zUMsuO2zXOuLLcwCSFN+73GBLWocCxBvag6HFvCemy5Tuhs
411be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * 9MhfF+5lKER/9Ama/e7C61usaoUhR1OvpGWMfjewrFLCsyWlInscoZ1ad5YtcWGx
412be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * MM7+BsTnK00fcXZuPHTPsiwQ0fMVeNM2a/e65aIivfzzHmb6gqUigNpfNYcqQsJJ
413be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * Wwoc5hXVO92vugdHOHOiAUpfZZgNDZwgCTluMuI+KJ0QCb0dhF5w/TDA8z+vRwmW
414be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * sz5WrA4F+T3LfwwLQfxJyHTnbAu38VlMMZP98iIobOX3AAkBw4+kTOCEedvmKt0f
415be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * s7iSKrnnV6AyzRPEJUWknMF8xNFH7HDqkZf4Mv8cMM6e45K4kBGd17d3tcEFi2An
416be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * 5l6S9hHtoyMhHjnAcyuHJbD9rGRgyOlbhSYTcbX/gKiECZj0kf8xHi20qntO3c+p
417be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * jdpp97fIMnQTl5IDNxOy5h9MDLs/SYAR7iyF19RkIGc=
418be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * -----END RSA PRIVATE KEY-----
419be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     */
420f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
421be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob    /*
4221cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob       Certificate:
4231cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob           Data:
4241cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Version: 3 (0x2)
4251cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Serial Number: 2 (0x2)
4261cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Signature Algorithm: sha1WithRSAEncryption
4271cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Issuer: C=AN, ST=Android, O=Android, OU=Android, CN=Android/emailAddress=android@android.com
4281cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Validity
4291cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                   Not Before: Mar 20 17:02:32 2009 GMT
4301cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                   Not After : Mar 20 17:02:32 2010 GMT
4311cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Subject: C=AN, ST=Android, L=Android, O=Android, OU=Android, CN=Android/emailAddress=android@android.com
4321cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               Subject Public Key Info:
4331cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                   Public Key Algorithm: rsaEncryption
4341cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                   RSA Public Key: (1024 bit)
4351cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       Modulus (1024 bit):
4361cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           00:b4:c5:ed:df:30:42:6d:8b:af:4b:e4:9c:13:5e:
4371cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           83:23:cd:2f:ce:34:e2:43:d7:6c:72:bb:03:b3:b9:
4381cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           24:02:e0:cc:b5:8d:d6:92:41:04:2b:5c:94:b2:c3:
4391cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           9c:9d:56:f0:99:bc:0f:81:af:eb:54:ed:80:a6:a0:
4401cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           c7:c2:43:05:04:7c:9c:7e:07:03:10:b9:bd:c5:16:
4411cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           cf:19:dd:e3:4f:73:83:72:c5:66:e4:5b:14:c4:96:
4421cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           d1:e3:24:0b:b6:d4:f7:84:2e:b1:e7:93:02:9d:f5:
4431cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           da:aa:c1:d9:cc:5e:36:e9:8f:bf:8b:da:a7:45:82:
4441cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                           f2:b0:f5:a7:e4:e1:80:a3:17
4451cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       Exponent: 65537 (0x10001)
4461cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               X509v3 extensions:
447f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes                   X509v3 Basic Constraints:
4481cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       CA:FALSE
449f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes                   Netscape Comment:
4501cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       OpenSSL Generated Certificate
451f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes                   X509v3 Subject Key Identifier:
4521cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       3B:5B:3D:DB:45:F5:8F:58:70:0B:FC:70:3E:31:2B:43:63:A9:FE:2B
453f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes                   X509v3 Authority Key Identifier:
4541cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob                       keyid:E7:9B:7D:90:29:EA:90:0B:7F:08:41:76:4E:41:23:E8:43:2C:A9:03
4551cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob
4561cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob           Signature Algorithm: sha1WithRSAEncryption
4571cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               1c:7f:93:1c:59:21:88:15:45:4b:e0:9c:78:3a:88:3e:55:19:
4581cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               86:31:e8:53:3d:74:e2:4a:34:9f:92:17:4e:13:46:92:54:f8:
4591cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               43:eb:5e:03:4f:14:51:61:d2:04:b8:04:5a:31:eb:14:6a:18:
4601cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               b0:20:03:92:0c:7f:07:c4:1b:f9:9e:7f:5f:ec:03:7a:c8:e3:
4611cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               df:d3:94:6e:68:8a:3a:3d:e4:61:f3:e0:87:5d:40:d8:cb:99:
4621cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               4d:9a:7b:bc:95:7c:d2:9d:b7:04:9a:9a:63:89:cd:39:ec:32:
4631cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               60:0a:97:da:e9:50:a5:73:4a:a2:aa:9c:9b:a8:7f:5a:20:d6:
4641cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob               48:bd
465be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     */
4661cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob    String certificate3 = "-----BEGIN CERTIFICATE-----\n"
4671cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            + "MIIC9jCCAl+gAwIBAgIBAjANBgkqhkiG9w0BAQUFADB5MQswCQYDVQQGEwJBTjEQ\n"
4681cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            + "MA4GA1UECBMHQW5kcm9pZDEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5k\n"
4691cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            + "cm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBh\n"
4701cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            + "bmRyb2lkLmNvbTAeFw0wOTAzMjAxNzAyMzJaFw0xMDAzMjAxNzAyMzJaMIGLMQsw\n"
4711cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            + "CQYDVQQGEwJBTjEQMA4GA1UECBMHQW5kcm9pZDEQMA4GA1UEBxMHQW5kcm9pZDEQ\n"
4721cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            + "MA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5k\n"
4731cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            + "cm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCBnzANBgkq\n"
4741cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            + "hkiG9w0BAQEFAAOBjQAwgYkCgYEAtMXt3zBCbYuvS+ScE16DI80vzjTiQ9dscrsD\n"
4751cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            + "s7kkAuDMtY3WkkEEK1yUssOcnVbwmbwPga/rVO2ApqDHwkMFBHycfgcDELm9xRbP\n"
4761cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            + "Gd3jT3ODcsVm5FsUxJbR4yQLttT3hC6x55MCnfXaqsHZzF426Y+/i9qnRYLysPWn\n"
4771cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            + "5OGAoxcCAwEAAaN7MHkwCQYDVR0TBAIwADAsBglghkgBhvhCAQ0EHxYdT3BlblNT\n"
4781cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            + "TCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFDtbPdtF9Y9YcAv8cD4x\n"
4791cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            + "K0Njqf4rMB8GA1UdIwQYMBaAFOebfZAp6pALfwhBdk5BI+hDLKkDMA0GCSqGSIb3\n"
4801cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            + "DQEBBQUAA4GBABx/kxxZIYgVRUvgnHg6iD5VGYYx6FM9dOJKNJ+SF04TRpJU+EPr\n"
4811cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            + "XgNPFFFh0gS4BFox6xRqGLAgA5IMfwfEG/mef1/sA3rI49/TlG5oijo95GHz4Idd\n"
4821cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            + "QNjLmU2ae7yVfNKdtwSammOJzTnsMmAKl9rpUKVzSqKqnJuof1og1ki9\n"
4831cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            + "-----END CERTIFICATE-----";
4841cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob
4851cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob    ByteArrayInputStream certArray3 = new ByteArrayInputStream(certificate3
4861cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            .getBytes());
487be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob
488be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob    /*
489be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * The key in DER format.
490f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     * Below is the same key in PEM format as reference
491be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     */
492051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann    byte[] key3Bytes = new byte[] {
493051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x30, (byte)0x82, (byte)0x02, (byte)0x76, (byte)0x02, (byte)0x01, (byte)0x00,
494051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x30, (byte)0x0d, (byte)0x06, (byte)0x09, (byte)0x2a, (byte)0x86, (byte)0x48,
495051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x86, (byte)0xf7, (byte)0x0d, (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x05,
496051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x00, (byte)0x04, (byte)0x82, (byte)0x02, (byte)0x60, (byte)0x30, (byte)0x82,
497051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x02, (byte)0x5c, (byte)0x02, (byte)0x01, (byte)0x00, (byte)0x02, (byte)0x81,
498051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x81, (byte)0x00, (byte)0xb4, (byte)0xc5, (byte)0xed, (byte)0xdf, (byte)0x30,
499051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x42, (byte)0x6d, (byte)0x8b, (byte)0xaf, (byte)0x4b, (byte)0xe4, (byte)0x9c,
500051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x13, (byte)0x5e, (byte)0x83, (byte)0x23, (byte)0xcd, (byte)0x2f, (byte)0xce,
501051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x34, (byte)0xe2, (byte)0x43, (byte)0xd7, (byte)0x6c, (byte)0x72, (byte)0xbb,
502051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x03, (byte)0xb3, (byte)0xb9, (byte)0x24, (byte)0x02, (byte)0xe0, (byte)0xcc,
503051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xb5, (byte)0x8d, (byte)0xd6, (byte)0x92, (byte)0x41, (byte)0x04, (byte)0x2b,
504051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x5c, (byte)0x94, (byte)0xb2, (byte)0xc3, (byte)0x9c, (byte)0x9d, (byte)0x56,
505051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xf0, (byte)0x99, (byte)0xbc, (byte)0x0f, (byte)0x81, (byte)0xaf, (byte)0xeb,
506051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x54, (byte)0xed, (byte)0x80, (byte)0xa6, (byte)0xa0, (byte)0xc7, (byte)0xc2,
507051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x43, (byte)0x05, (byte)0x04, (byte)0x7c, (byte)0x9c, (byte)0x7e, (byte)0x07,
508051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x03, (byte)0x10, (byte)0xb9, (byte)0xbd, (byte)0xc5, (byte)0x16, (byte)0xcf,
509051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x19, (byte)0xdd, (byte)0xe3, (byte)0x4f, (byte)0x73, (byte)0x83, (byte)0x72,
510051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xc5, (byte)0x66, (byte)0xe4, (byte)0x5b, (byte)0x14, (byte)0xc4, (byte)0x96,
511051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xd1, (byte)0xe3, (byte)0x24, (byte)0x0b, (byte)0xb6, (byte)0xd4, (byte)0xf7,
512051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x84, (byte)0x2e, (byte)0xb1, (byte)0xe7, (byte)0x93, (byte)0x02, (byte)0x9d,
513051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xf5, (byte)0xda, (byte)0xaa, (byte)0xc1, (byte)0xd9, (byte)0xcc, (byte)0x5e,
514051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x36, (byte)0xe9, (byte)0x8f, (byte)0xbf, (byte)0x8b, (byte)0xda, (byte)0xa7,
515051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x45, (byte)0x82, (byte)0xf2, (byte)0xb0, (byte)0xf5, (byte)0xa7, (byte)0xe4,
516051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xe1, (byte)0x80, (byte)0xa3, (byte)0x17, (byte)0x02, (byte)0x03, (byte)0x01,
517051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x81, (byte)0x80, (byte)0x53, (byte)0xbc,
518051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x1f, (byte)0x1c, (byte)0x34, (byte)0x09, (byte)0x81, (byte)0x1e, (byte)0xa3,
519051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xfb, (byte)0x5e, (byte)0x90, (byte)0xa1, (byte)0x34, (byte)0x35, (byte)0x40,
520051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x9f, (byte)0x29, (byte)0xd6, (byte)0xb5, (byte)0x8e, (byte)0x5d, (byte)0x68,
521051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x6a, (byte)0xf6, (byte)0x96, (byte)0x03, (byte)0xf7, (byte)0xfa, (byte)0xf9,
522051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x60, (byte)0x4f, (byte)0xea, (byte)0xe2, (byte)0xea, (byte)0x29, (byte)0x8b,
523051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x23, (byte)0x8c, (byte)0x9f, (byte)0xdd, (byte)0x49, (byte)0x8f, (byte)0xa8,
524051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xa6, (byte)0x62, (byte)0x07, (byte)0x44, (byte)0x79, (byte)0xa1, (byte)0xaf,
525051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xf9, (byte)0x1d, (byte)0x98, (byte)0xbf, (byte)0x85, (byte)0x28, (byte)0x03,
526051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x87, (byte)0x14, (byte)0x20, (byte)0xba, (byte)0xd4, (byte)0x96, (byte)0x61,
527051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x2a, (byte)0xd0, (byte)0xaa, (byte)0x30, (byte)0x19, (byte)0x4b, (byte)0x40,
528051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x35, (byte)0xb0, (byte)0x79, (byte)0x0b, (byte)0x7f, (byte)0xd7, (byte)0xcd,
529051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x64, (byte)0xd9, (byte)0x93, (byte)0x38, (byte)0xe2, (byte)0x59, (byte)0xe0,
530051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x9e, (byte)0x3a, (byte)0x25, (byte)0x27, (byte)0xa2, (byte)0xd9, (byte)0x20,
531051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xb0, (byte)0x45, (byte)0x5f, (byte)0x6c, (byte)0x15, (byte)0x6f, (byte)0x10,
532051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x55, (byte)0xa7, (byte)0xf9, (byte)0x3d, (byte)0x92, (byte)0x3c, (byte)0x7c,
533051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x23, (byte)0x1b, (byte)0xc0, (byte)0xb5, (byte)0x17, (byte)0x41, (byte)0x5e,
534051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x8c, (byte)0xdc, (byte)0x25, (byte)0x1d, (byte)0x35, (byte)0x2b, (byte)0xd3,
535051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x97, (byte)0x1a, (byte)0x6f, (byte)0xae, (byte)0xeb, (byte)0xf5, (byte)0xf9,
536051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x02, (byte)0x41, (byte)0x00, (byte)0xd7, (byte)0x3e, (byte)0xed, (byte)0x70,
537051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xfe, (byte)0xee, (byte)0x0e, (byte)0x30, (byte)0x29, (byte)0xfa, (byte)0xd7,
538051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x38, (byte)0xcf, (byte)0x8e, (byte)0xc1, (byte)0x9c, (byte)0x78, (byte)0x06,
539051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x2d, (byte)0xda, (byte)0x33, (byte)0x58, (byte)0xa1, (byte)0x7b, (byte)0xbf,
540051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x00, (byte)0xb9, (byte)0xdf, (byte)0xea, (byte)0x65, (byte)0x86, (byte)0xbb,
541051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xcc, (byte)0x83, (byte)0xce, (byte)0xde, (byte)0xc3, (byte)0xf8, (byte)0x89,
542051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xf5, (byte)0x9f, (byte)0xa6, (byte)0x1d, (byte)0xc9, (byte)0xfb, (byte)0x98,
543051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xa1, (byte)0x2e, (byte)0xe0, (byte)0x57, (byte)0x6e, (byte)0xbd, (byte)0x57,
544051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x20, (byte)0xf9, (byte)0x6b, (byte)0x13, (byte)0x42, (byte)0x9d, (byte)0x8d,
545051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x66, (byte)0x4d, (byte)0x7a, (byte)0x2d, (byte)0x02, (byte)0x41, (byte)0x00,
546051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xd7, (byte)0x00, (byte)0x18, (byte)0x54, (byte)0xe8, (byte)0x37, (byte)0xdb,
547051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xf8, (byte)0x98, (byte)0x7b, (byte)0x18, (byte)0x33, (byte)0xf6, (byte)0x28,
548051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xa8, (byte)0x8c, (byte)0xd9, (byte)0xfd, (byte)0x4c, (byte)0x4e, (byte)0x41,
549051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x73, (byte)0x2e, (byte)0x79, (byte)0x31, (byte)0xcc, (byte)0x7d, (byte)0x42,
550051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xb7, (byte)0xa1, (byte)0xd2, (byte)0xbc, (byte)0x1f, (byte)0x62, (byte)0xcf,
551051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x15, (byte)0x7c, (byte)0x62, (byte)0x97, (byte)0x70, (byte)0xf1, (byte)0x15,
552051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xf1, (byte)0x33, (byte)0xa1, (byte)0x9d, (byte)0xbb, (byte)0x5f, (byte)0xd7,
553051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x5a, (byte)0xf9, (byte)0x24, (byte)0x58, (byte)0xac, (byte)0x86, (byte)0x6a,
554051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xed, (byte)0xd4, (byte)0x84, (byte)0xe4, (byte)0x3f, (byte)0xfe, (byte)0xb0,
555051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xd3, (byte)0x02, (byte)0x41, (byte)0x00, (byte)0xd4, (byte)0xb7, (byte)0x84,
556051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xb2, (byte)0x39, (byte)0xce, (byte)0x0b, (byte)0x49, (byte)0x80, (byte)0x03,
557051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x3c, (byte)0xb5, (byte)0x11, (byte)0x32, (byte)0x34, (byte)0x96, (byte)0xac,
558051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x6a, (byte)0xf6, (byte)0xdf, (byte)0x80, (byte)0x04, (byte)0xe4, (byte)0x39,
559051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xc6, (byte)0x0e, (byte)0x32, (byte)0xa3, (byte)0x5e, (byte)0x23, (byte)0x0d,
560051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x9f, (byte)0x04, (byte)0xc3, (byte)0x72, (byte)0x2a, (byte)0xe6, (byte)0xa2,
561051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xf5, (byte)0xbc, (byte)0x3f, (byte)0x15, (byte)0x4c, (byte)0xb5, (byte)0x33,
562051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x26, (byte)0xa8, (byte)0x8c, (byte)0x09, (byte)0xfb, (byte)0x7e, (byte)0x1e,
563051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x32, (byte)0x40, (byte)0x0d, (byte)0x1d, (byte)0xcb, (byte)0x7f, (byte)0xf6,
564051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xf2, (byte)0x29, (byte)0x9b, (byte)0x01, (byte)0xd5, (byte)0x02, (byte)0x40,
565051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x24, (byte)0x26, (byte)0x1c, (byte)0xf1, (byte)0x31, (byte)0xb6, (byte)0x2a,
566051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xa3, (byte)0x0a, (byte)0xa8, (byte)0x2f, (byte)0xb2, (byte)0x94, (byte)0xe1,
567051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xd3, (byte)0x2d, (byte)0x13, (byte)0x7d, (byte)0xd6, (byte)0x35, (byte)0x96,
568051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x25, (byte)0x92, (byte)0x9b, (byte)0xc7, (byte)0xf6, (byte)0xb4, (byte)0xdc,
569051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xe1, (byte)0xd9, (byte)0x30, (byte)0x80, (byte)0x76, (byte)0xda, (byte)0x7b,
570051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x2d, (byte)0x06, (byte)0xa3, (byte)0xe1, (byte)0x08, (byte)0x99, (byte)0x50,
571051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x72, (byte)0x24, (byte)0x97, (byte)0x38, (byte)0xd9, (byte)0x07, (byte)0x4d,
572051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x43, (byte)0x3b, (byte)0x7e, (byte)0x93, (byte)0xf6, (byte)0x36, (byte)0x07,
573051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x86, (byte)0x83, (byte)0x63, (byte)0xf0, (byte)0xa8, (byte)0x9d, (byte)0xdf,
574051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x07, (byte)0x02, (byte)0x40, (byte)0x3e, (byte)0x58, (byte)0x03, (byte)0xbf,
575051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xea, (byte)0x3e, (byte)0x34, (byte)0x2c, (byte)0xb7, (byte)0xc3, (byte)0x09,
576051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xe9, (byte)0xf4, (byte)0x43, (byte)0x41, (byte)0xc4, (byte)0x7c, (byte)0x6e,
577051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x75, (byte)0x72, (byte)0x5d, (byte)0xfc, (byte)0xa3, (byte)0x75, (byte)0x1d,
578051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xa0, (byte)0xee, (byte)0xc2, (byte)0x1f, (byte)0x71, (byte)0xb0, (byte)0xf3,
579051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x1d, (byte)0xec, (byte)0x81, (byte)0xdb, (byte)0x45, (byte)0xe5, (byte)0x6a,
580051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xe8, (byte)0xe0, (byte)0x64, (byte)0x90, (byte)0xff, (byte)0xb9, (byte)0xf8,
581051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0x12, (byte)0xed, (byte)0x55, (byte)0x5c, (byte)0x9b, (byte)0x81, (byte)0xcd,
582051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xbb, (byte)0x06, (byte)0x91, (byte)0xfe, (byte)0x27, (byte)0x2c, (byte)0x3a,
583051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann            (byte)0xed, (byte)0x96, (byte)0x3b, (byte)0xfe
584051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann    };
585f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
586051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann    /*
587be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * The same key in PEM format.
588be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * The DER version of this key was created using
589f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
590be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * openssl pkcs8 -topk8 -nocrypt -in key1.pem
591be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     *         -inform PEM -out key1.der -outform DER
592f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
593be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * -----BEGIN RSA PRIVATE KEY-----
594be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * Proc-Type: 4,ENCRYPTED
595be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * DEK-Info: DES-EDE3-CBC,0EE6B33EC2D92297
596f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes     *
597be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * r7lbWwtlmubgMG020XiOStqgrvPkP1hTrbOV7Gh2IVNTyXWyA8UriQlPyqBQNzy2
598be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * 5+Z+JUqzYoLCGY0fQ95ck+ya/wHJQX4OSKFOZwQKpU7pEY9wN1YPa7U9ZnyCPGtB
599be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * +ejvHuIMJhE5wq9Y1iEDIlON++onWTf4T36Sz3OQ8gEJbnx3x+UjcCINooj7kOeM
600be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * giCi5yJEOJaf4fkRioUh6S7cm/msTH3ID33rrvTjk7cD8mGzzTy4hWyKaK4K9GbC
601be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * dOvSORM9mVwTWMUdu1wJ5uyadwBhpSIhC/qpP8Je60nFy8YJlzB2FaMUpAuIOM7B
602be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * EVN2uAMDNOpGzcOJPbLig8smk2lA4+y1T3gFd9paskSjD9B8+/3KuagWEEQQL7T4
603be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * YK3xtjzXwEp6OdG2QjD4ZcK5D0MKuYPF3PszwzlCnBG/On6wIvIiTPWBn/G2u59D
604be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * gJPV7V3Jipn0iYYN+i7T5TNoT7Vko8s3BRpVSrlFUFFhtQPad6NcxGNNH5L1g3fF
605be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * +dp4TnG64PCQZtuu6I6gfuMXztOwQtEpxxHo9WktlCpwL0tT/tpx+zOVbLvgusjB
606be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * QKYCIplbSI7VtpOfcJ3kTTAWSOGZli4FayB/Dplf/FXN6ZwwASw09ioVQc/CFdLk
607be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * Xw05elxV8/AFvm+/VkUHK5JJSp32WMgAJA+XrUsOb5lw1Tl3Hlj9KHALp+Pt/i7N
608be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * +LPnxrpuTry31APt8aRup/pWOLa+f97Hz+arp4wJa5LK+GtTTtoI4+QZp5qzR/jy
609be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * oM+DoKtK+1WsCU7teJwEWXV/ayo1TEFEhcY0F7IAPCzDlG3XOFmulQ==
610be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     * -----END RSA PRIVATE KEY-----
611be25811712488827cf836ee6170eca8fb4e14fe4Urs Grob     */
6121cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob
6131cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob    @Override
6141cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob    protected void setUp() {
6151cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        String defAlg = KeyManagerFactory.getDefaultAlgorithm();
6161cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        try {
6171cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            factory = KeyManagerFactory.getInstance(defAlg);
6181cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        } catch (NoSuchAlgorithmException e) {
6191cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob            fail("could not get default KeyManagerFactory");
6201cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        }
6211cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob    }
622f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
6231cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob    void init(String name) {
6241cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob      keyType = name;
6251cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob      try {
6261cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob          CertificateFactory cf = CertificateFactory.getInstance("X.509");
6271cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob          KeyFactory kf = KeyFactory.getInstance("RSA");
6281cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob          keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
629051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann          keyTest.load(null, "1234".toCharArray());
6308272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom          if (keyType.equals(CLIENT)) {
6311cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob              keys = new PrivateKey[3];
632051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann              keys[0] = kf.generatePrivate(new PKCS8EncodedKeySpec(keyBytes));
633051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann              keys[1] = kf.generatePrivate(new PKCS8EncodedKeySpec(key2Bytes));
634051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann              keys[2] = kf.generatePrivate(new PKCS8EncodedKeySpec(key3Bytes));
6351cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob              cert = new X509Certificate[3];
6361cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob              cert[0] = (X509Certificate) cf.generateCertificate(certArray);
6371cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob              cert[1] = (X509Certificate) cf.generateCertificate(certArray2);
6381cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob              cert[2] = (X509Certificate) cf.generateCertificate(certArray3);
6398272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom              keyTest.setKeyEntry("clientKey_01", keys[0], PASSWORD, new X509Certificate[] {cert[0]});
6408272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom              keyTest.setKeyEntry("clientKey_02", keys[1], PASSWORD, new X509Certificate[] {cert[0], cert[1]});
6418272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom              keyTest.setKeyEntry("clientKey_03", keys[2], PASSWORD, new X509Certificate[] {cert[0], cert[2]});
6421cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob              keyTest.setCertificateEntry("clientAlias_01", cert[0]);
6431cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob              keyTest.setCertificateEntry("clientAlias_02", cert[0]);
6441cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob              keyTest.setCertificateEntry("clientAlias_03", cert[1]);
6458272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom          } else if (keyType.equals(SERVER)) {
646051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann              keys = new PrivateKey[1];
647051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann              keys[0] = kf.generatePrivate(new PKCS8EncodedKeySpec(keyBytes));
6481cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob              cert = new X509Certificate[1];
6491cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob              cert[0] = (X509Certificate) cf.generateCertificate(certArray3);
6508272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom              keyTest.setKeyEntry("serverKey_00", keys[0], PASSWORD, new X509Certificate[] {cert[0]});
6511cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob              keyTest.setCertificateEntry("serverAlias_00", cert[0]);
6521cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob          }
6531cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob      } catch (Exception ex) {
6541cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob          ex.printStackTrace();
6551cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob          throw new IllegalArgumentException(ex.getMessage());
6561cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob      }
6571cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob      try {
658051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann        factory.init(keyTest, "1234".toCharArray());
6591cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob      } catch (Exception e) {
6601cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        fail("Could't init the KeyManagerFactory");
6611cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob      }
6621cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob      manager = (X509KeyManager) factory.getKeyManagers()[0];
6631cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob    }
664f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
665adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    /**
6668272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom     * X509KeyManager#getClientAliases(String keyType, Principal[] issuers)
667adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     */
668adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    public void test_getClientAliases() {
6698272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        init(CLIENT);
6701cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertNull(manager.getClientAliases(null, null));
6711cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertNull(manager.getClientAliases("", null));
6728272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        String[] resArray = manager.getClientAliases(TYPE_RSA, null);
6731cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertNotNull(resArray);
6748272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        assertEquals(3, resArray.length);
6758272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        assertKnownAliases(resArray);
676adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    }
677f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
678adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    /**
6798272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom     * X509KeyManager#chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket)
680adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     */
681adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    public void test_chooseClientAlias() {
6828272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        init(CLIENT);
6831cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertNull(manager.chooseClientAlias(null, null, new Socket()));
6841cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertNull(manager.chooseClientAlias(new String[0], null, new Socket()));
6858272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        assertNull(manager.chooseClientAlias(new String[]{"BOGUS"}, null, new Socket()));
6868272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        String res = manager.chooseClientAlias(new String[]{TYPE_RSA}, null, null);
687051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann        assertNotNull(res);
6888272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        assertKnownAlias(res);
689adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    }
690f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
691adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    /**
6928272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom     * X509KeyManager#getServerAliases(String keyType, Principal[] issuers)
693adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     */
694adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    public void test_getServerAliases() {
6958272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        init(SERVER);
6961cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertNull(manager.getServerAliases(null, null));
6971cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertNull(manager.getServerAliases("", null));
6988272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        String[] resArray = manager.getServerAliases(TYPE_RSA, null);
6991cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertNotNull(resArray);
7001cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertEquals("Incorrect length", 1, resArray.length);
701051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann        assertEquals("Incorrect aliase", "serverkey_00", resArray[0].toLowerCase());
702adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    }
703f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
704adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    /**
7058272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom     * X509KeyManager#chooseServerAlias(String keyType, Principal[] issuers, Socket socket)
706adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     */
707adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    public void test_chooseServerAlias() {
7088272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        init(SERVER);
7091cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertNull(manager.chooseServerAlias(null, null, new Socket()));
7101cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertNull(manager.chooseServerAlias("", null, new Socket()));
7118272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        String res = manager.chooseServerAlias(TYPE_RSA, null, null);
712051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann        assertNotNull(res);
713051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann        assertEquals("serverkey_00", res.toLowerCase());
7148272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        res = manager.chooseServerAlias(TYPE_RSA, null, new Socket());
715051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann        assertNotNull(res);
716051f400949489d012498f575c0a40999ad7a4f54Jorg Pleumann        assertEquals("serverkey_00", res.toLowerCase());
717adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    }
718f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
719adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    /**
7208272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom     * X509KeyManager#getCertificateChain(String alias)
721adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     */
722adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    public void test_getCertificateChain() {
7238272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        init(SERVER);
7241cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertNull("Not NULL for NULL parameter", manager.getCertificateChain(null));
7251cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertNull("Not NULL for empty parameter",manager.getCertificateChain(""));
7261cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertNull("Not NULL for clientAlias_01 parameter", manager.getCertificateChain("clientAlias_01"));
7271cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertNull("Not NULL for serverAlias_00 parameter", manager.getCertificateChain("serverAlias_00"));
728adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    }
729f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
730adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    /**
7318272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom     * X509KeyManager#getPrivateKey(String alias)
732adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project     */
733adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    public void test_getPrivateKey() {
7348272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        init(CLIENT);
7351cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertNull("Not NULL for NULL parameter", manager.getPrivateKey(null));
7361cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertNull("Not NULL for serverAlias_00 parameter", manager.getPrivateKey("serverAlias_00"));
7371cd5a5cfeccb2745d54a1c49fc39e4e3537a9adeUrs Grob        assertNull("Not NULL for clientAlias_02 parameter", manager.getPrivateKey("clientAlias_02"));
738adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    }
739f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
740f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes
7418272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom    private void assertKnownAliases(String[] aliases) {
7428272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        for (String alias : aliases) {
7438272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom            assertKnownAlias(alias);
744adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project        }
7458272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom    }
7468272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom
7478272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom    private void assertKnownAlias(String alias) {
7488272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        String a = alias.toLowerCase();
7498272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        boolean okay = a.equals("clientkey_01") || a.equals("clientkey_02") || a.equals("clientkey_03");
7508272b935bd238a37846ea76b8fcfe297abe1c7eeBrian Carlstrom        assertTrue("Expected one of clientkey_01, clientkey_02, clientkey_03. Received: " + alias, okay);
751adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project    }
752adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project}
753adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project
754