diff options
author | Brian Carlstrom <bdc@google.com> | 2013-01-04 15:47:39 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-01-04 15:47:39 -0800 |
commit | bc7d5a55b22ce30af250cc7468b6c5987cd25dfd (patch) | |
tree | dcf9f00a2f7ed7c9e8f515ba70adf5f51eeddb44 /core/tests/coretests | |
parent | 81cfb63e9fc6ef72e5b488225fe9b7a43551fc9e (diff) | |
parent | 537fb0afe24a520e7b9a2442786b6fb4fe194392 (diff) | |
download | frameworks_base-bc7d5a55b22ce30af250cc7468b6c5987cd25dfd.zip frameworks_base-bc7d5a55b22ce30af250cc7468b6c5987cd25dfd.tar.gz frameworks_base-bc7d5a55b22ce30af250cc7468b6c5987cd25dfd.tar.bz2 |
am 537fb0af: Merge "Use most specific attributes for distinguished name display"
* commit '537fb0afe24a520e7b9a2442786b6fb4fe194392':
Use most specific attributes for distinguished name display
Diffstat (limited to 'core/tests/coretests')
-rw-r--r-- | core/tests/coretests/src/android/net/http/SslCertificateTest.java | 69 |
1 files changed, 64 insertions, 5 deletions
diff --git a/core/tests/coretests/src/android/net/http/SslCertificateTest.java b/core/tests/coretests/src/android/net/http/SslCertificateTest.java index 147816b..6a30c6c 100644 --- a/core/tests/coretests/src/android/net/http/SslCertificateTest.java +++ b/core/tests/coretests/src/android/net/http/SslCertificateTest.java @@ -45,11 +45,70 @@ public class SslCertificateTest extends TestCase { @LargeTest public void testSslCertificateWithEmptyIssuer() throws Exception { - CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); - X509Certificate x509Certificate = (X509Certificate) - certificateFactory.generateCertificate(new ByteArrayInputStream(Issue1597Certificate.getBytes())); - assertEquals(x509Certificate.getIssuerDN().getName(), ""); + X509Certificate x509Certificate = generateCertificate(Issue1597Certificate); + assertEquals("", x509Certificate.getSubjectDN().getName()); SslCertificate sslCertificate = new SslCertificate(x509Certificate); - assertEquals(sslCertificate.getIssuedBy().getDName(), ""); + assertEquals("", sslCertificate.getIssuedBy().getDName()); } + + /** + * Problematic certificate from Issue 41662 + * http://code.google.com/p/android/issues/detail?id=41662 + */ + private static final String Issue41662Certificate = + "-----BEGIN CERTIFICATE-----\n"+ + "MIIG6jCCBdKgAwIBAgIESPx/LDANBgkqhkiG9w0BAQUFADCBrjESMBAGCgmSJomT\n"+ + "8ixkARkWAnJzMRUwEwYKCZImiZPyLGQBGRYFcG9zdGExEjAQBgoJkiaJk/IsZAEZ\n"+ + "FgJjYTEWMBQGA1UEAxMNQ29uZmlndXJhdGlvbjERMA8GA1UEAxMIU2VydmljZXMx\n"+ + "HDAaBgNVBAMTE1B1YmxpYyBLZXkgU2VydmljZXMxDDAKBgNVBAMTA0FJQTEWMBQG\n"+ + "A1UEAxMNUG9zdGEgQ0EgUm9vdDAeFw0wODEwMjAxNDExMzBaFw0yODEwMTQyMjAw\n"+ + "MDBaMIGrMRIwEAYKCZImiZPyLGQBGRYCcnMxFTATBgoJkiaJk/IsZAEZFgVwb3N0\n"+ + "YTESMBAGCgmSJomT8ixkARkWAmNhMRYwFAYDVQQDEw1Db25maWd1cmF0aW9uMREw\n"+ + "DwYDVQQDEwhTZXJ2aWNlczEcMBoGA1UEAxMTUHVibGljIEtleSBTZXJ2aWNlczEM\n"+ + "MAoGA1UEAxMDQUlBMRMwEQYDVQQDEwpQb3N0YSBDQSAxMIIBIjANBgkqhkiG9w0B\n"+ + "AQEFAAOCAQ8AMIIBCgKCAQEAl5msW5MdLW/2aDlezrjU3jW58MKrcMPHs2szlGdL\n"+ + "nsAcSyYFF1JbyA8iuqLp7mhvcTz9m4jK82XBz/1mPq8wJMU9ekGnLhgbKLGKXRBA\n"+ + "sY9wzCvwpweQV6ui4vr2eOkS1j9Mk7ikatH8tNiIzkNrTj3npDpZv1w4G37iwtpb\n"+ + "yjg+lkNIDY2nWV9roBsAZM8Lvbyi4vxP41YEQZ3hxaGGG0/RKHbugvGatgckxfin\n"+ + "4gpFG2mDhS9uafGgqnLHLwpxgBbi3g6+2TsxOKatTxwx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pa2F0aS5jYS5wb3N0YS5ycy9jcmwv\n"+ + "UG9zdGFDQVJvb3QuY3JsMB8GA1UdIwQYMBaAFPLLjeI17xBDxNp7yvrriQOhIq+4\n"+ + "MB0GA1UdDgQWBBQuZ6cm1uhncOeq+pAsMLzXYWUfhjAZBgkqhkiG9n0HQQAEDDAK\n"+ + "GwRWNy4xAwIAgTANBgkqhkiG9w0BAQUFAAOCAQEAjpmoaebsvfjgwgCYArou/s8k\n"+ + "Tr50TUdcJYxAYmCFQp531E1F+qUCWM/7bZApqByR3+EUz8goI5O2Cp/6ISxTR1HC\n"+ + "Dn71ESg7/c8Bs2Obx0LGYPnlRPvw7LH31dYXpj4EMNAamhOfBXgY2htXHCd7daIe\n"+ + "thvNkqWGDzmcoaGw/2BMNadlYkdXxudDBaiPDFm27yR7fPRibjxwkQVknzFezX/y\n"+ + "46j+20LoGJ/IpneT209XzytiaqtZBy3yqz2qImVDqvn5doHw63LOUqt8vfDS1sbd\n"+ + "zi3acAmPK1nERdCMJYJEEGNiGbkbw2cghwLw/4eYGXlj1VLXD3GU42uBr8QftA==\n"+ + "-----END CERTIFICATE-----\n"; + + @LargeTest + public void testSslCertificateWithMultipleCN() throws Exception { + X509Certificate x509Certificate = generateCertificate(Issue41662Certificate); + String dn = x509Certificate.getSubjectDN().getName(); + assertTrue(dn, dn.contains("Posta CA 1")); + assertTrue(dn, dn.contains("Configuration")); + SslCertificate sslCertificate = new SslCertificate(x509Certificate); + assertEquals(dn, "Posta CA 1", sslCertificate.getIssuedTo().getCName()); + } + + private static X509Certificate generateCertificate(String pem) throws Exception { + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + return (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(pem.getBytes())); + } + } |