Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.

SslError

public class SslError
extends Object

java.lang.Object
   ↳ android.net.http.SslError


This class represents a set of one or more SSL errors and the associated SSL certificate.

Summary

Constants

int SSL_DATE_INVALID

The date of the certificate is invalid

int SSL_EXPIRED

The certificate has expired

int SSL_IDMISMATCH

Hostname mismatch

int SSL_INVALID

A generic error occurred

int SSL_MAX_ERROR

This constant was deprecated in API level 14. This constant is not necessary for using the SslError API and can change from release to release.

int SSL_NOTYETVALID

The certificate is not yet valid

int SSL_UNTRUSTED

The certificate authority is not trusted

Public constructors

SslError(int error, SslCertificate certificate)

This constructor was deprecated in API level 14. Use SslError(int, SslCertificate, String)

SslError(int error, X509Certificate certificate)

This constructor was deprecated in API level 14. Use SslError(int, X509Certificate, String)

SslError(int error, SslCertificate certificate, String url)

Creates a new SslError object using the supplied error, certificate and URL.

SslError(int error, X509Certificate certificate, String url)

Creates a new SslError object using the supplied error, certificate and URL.

Public methods

boolean addError(int error)

Adds the supplied SSL error to the set.

SslCertificate getCertificate()

Gets the SSL certificate associated with this object.

int getPrimaryError()

Gets the most severe SSL error in this object's set of errors.

String getUrl()

Gets the URL associated with this object.

boolean hasError(int error)

Determines whether this object includes the supplied error.

String toString()

Returns a string representation of this object.

Inherited methods

Constants

SSL_DATE_INVALID

added in API level 14
public static final int SSL_DATE_INVALID

The date of the certificate is invalid

Constant Value: 4 (0x00000004)

SSL_EXPIRED

added in API level 8
public static final int SSL_EXPIRED

The certificate has expired

Constant Value: 1 (0x00000001)

SSL_IDMISMATCH

added in API level 8
public static final int SSL_IDMISMATCH

Hostname mismatch

Constant Value: 2 (0x00000002)

SSL_INVALID

added in API level 14
public static final int SSL_INVALID

A generic error occurred

Constant Value: 5 (0x00000005)

SSL_MAX_ERROR

added in API level 8
public static final int SSL_MAX_ERROR

This constant was deprecated in API level 14.
This constant is not necessary for using the SslError API and can change from release to release.

The number of different SSL errors.

Constant Value: 6 (0x00000006)

SSL_NOTYETVALID

added in API level 8
public static final int SSL_NOTYETVALID

The certificate is not yet valid

Constant Value: 0 (0x00000000)

SSL_UNTRUSTED

added in API level 8
public static final int SSL_UNTRUSTED

The certificate authority is not trusted

Constant Value: 3 (0x00000003)

Public constructors

SslError

added in API level 8
public SslError (int error, 
                SslCertificate certificate)

This constructor was deprecated in API level 14.
Use SslError(int, SslCertificate, String)

Creates a new SslError object using the supplied error and certificate. The URL will be set to the empty string.

Parameters
error int: The SSL error

certificate SslCertificate: The associated SSL certificate

SslError

added in API level 8
public SslError (int error, 
                X509Certificate certificate)

This constructor was deprecated in API level 14.
Use SslError(int, X509Certificate, String)

Creates a new SslError object using the supplied error and certificate. The URL will be set to the empty string.

Parameters
error int: The SSL error

certificate X509Certificate: The associated SSL certificate

SslError

added in API level 14
public SslError (int error, 
                SslCertificate certificate, 
                String url)

Creates a new SslError object using the supplied error, certificate and URL.

Parameters
error int: The SSL error

certificate SslCertificate: The associated SSL certificate

url String: The associated URL

SslError

added in API level 14
public SslError (int error, 
                X509Certificate certificate, 
                String url)

Creates a new SslError object using the supplied error, certificate and URL.

Parameters
error int: The SSL error

certificate X509Certificate: The associated SSL certificate

url String: The associated URL

Public methods

addError

added in API level 8
public boolean addError (int error)

Adds the supplied SSL error to the set.

Parameters
error int: The SSL error to add

Returns
boolean True if the error being added is a known SSL error, otherwise false.

getCertificate

added in API level 8
public SslCertificate getCertificate ()

Gets the SSL certificate associated with this object.

Returns
SslCertificate The SSL certificate, non-null.

getPrimaryError

added in API level 8
public int getPrimaryError ()

Gets the most severe SSL error in this object's set of errors. Returns -1 if the set is empty.

Returns
int The most severe SSL error, or -1 if the set is empty.

getUrl

added in API level 14
public String getUrl ()

Gets the URL associated with this object.

Returns
String The URL, non-null.

hasError

added in API level 8
public boolean hasError (int error)

Determines whether this object includes the supplied error.

Parameters
error int: The SSL error to check for

Returns
boolean True if this object includes the error, otherwise false.

toString

added in API level 8
public String toString ()

Returns a string representation of this object.

Returns
String A String representation of this object.