FileDocCategorySizeDatePackage
SslCertificateTest.javaAPI DocAndroid 5.1 API6405Thu Mar 12 22:22:12 GMT 2015android.net.http

SslCertificateTest

public class SslCertificateTest extends TestCase

Fields Summary
private static final String
Issue1597Certificate
Problematic certificate from Issue 1597 http://code.google.com/p/android/issues/detail?id=1597
private static final String
Issue41662Certificate
Problematic certificate from Issue 41662 http://code.google.com/p/android/issues/detail?id=41662
Constructors Summary
Methods Summary
private static java.security.cert.X509CertificategenerateCertificate(java.lang.String pem)

        CertificateFactory cf = CertificateFactory.getInstance("X.509");
        return (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(pem.getBytes()));
    
public voidtestSslCertificateWithEmptyIssuer()


    
         
        X509Certificate x509Certificate = generateCertificate(Issue1597Certificate);
        assertEquals("", x509Certificate.getSubjectDN().getName());
        SslCertificate sslCertificate = new SslCertificate(x509Certificate);
        assertEquals("", sslCertificate.getIssuedBy().getDName());
    
public voidtestSslCertificateWithMultipleCN()


    
         
        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());