Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6309c61d authored by Adam Vartanian's avatar Adam Vartanian
Browse files

Add getter for X509 certificate

Users have requested access to the underlying certificate, which is
usually available (as all non-deprecated constructors set it) and can
give access to additional properties that are useful to developers,
allow them to validate it with an X509TrustManager, or otherwise use
it with APIs that take an X509Certificate object.

Bug: 111696337
Bug: 36984840
Test: cts -m CtsNetTestCases -t android.net.http
Change-Id: I6aebaa38fad683e09e095e5b5e2f3424694ec426
parent 0cbdca3e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -26412,6 +26412,7 @@ package android.net.http {
    method public java.util.Date getValidNotAfterDate();
    method public deprecated java.lang.String getValidNotBefore();
    method public java.util.Date getValidNotBeforeDate();
    method public java.security.cert.X509Certificate getX509Certificate();
    method public static android.net.http.SslCertificate restoreState(android.os.Bundle);
    method public static android.os.Bundle saveState(android.net.http.SslCertificate);
  }
+11 −4
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package android.net.http;

import com.android.internal.util.HexDump;

import android.content.Context;
import android.os.Bundle;
import android.text.format.DateFormat;
@@ -25,6 +23,9 @@ import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.android.internal.util.HexDump;
import com.android.org.bouncycastle.asn1.x509.X509Name;

import java.io.ByteArrayInputStream;
import java.math.BigInteger;
import java.security.MessageDigest;
@@ -39,8 +40,6 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;

import com.android.org.bouncycastle.asn1.x509.X509Name;

/**
 * SSL certificate info (certificate details) class
 */
@@ -247,6 +246,14 @@ public class SslCertificate {
        return mIssuedBy;
    }

    /**
     * @return The {@code X509Certificate} used to create this {@code SslCertificate} or
     * {@code null} if no certificate was provided.
     */
    public X509Certificate getX509Certificate() {
        return mX509Certificate;
    }

    /**
     * Convenience for UI presentation, not intended as public API.
     */