summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/14.txt2
-rw-r--r--api/current.txt4
-rw-r--r--core/java/android/net/http/SslError.java39
3 files changed, 41 insertions, 4 deletions
diff --git a/api/14.txt b/api/14.txt
index 2a1bcac41a1f..895c44db7482 100644
--- a/api/14.txt
+++ b/api/14.txt
@@ -11206,7 +11206,7 @@ package android.net.http {
method public boolean hasError(int);
field public static final int SSL_EXPIRED = 1; // 0x1
field public static final int SSL_IDMISMATCH = 2; // 0x2
- field public static final int SSL_MAX_ERROR = 4; // 0x4
+ field public static final int SSL_MAX_ERROR = 6; // 0x6
field public static final int SSL_NOTYETVALID = 0; // 0x0
field public static final int SSL_UNTRUSTED = 3; // 0x3
}
diff --git a/api/current.txt b/api/current.txt
index 4b63c5bbe9ee..4135b5d69390 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -11541,9 +11541,11 @@ package android.net.http {
method public int getPrimaryError();
method public java.lang.String getUrl();
method public boolean hasError(int);
+ field public static final int SSL_DATE_INVALID = 4; // 0x4
field public static final int SSL_EXPIRED = 1; // 0x1
field public static final int SSL_IDMISMATCH = 2; // 0x2
- field public static final int SSL_MAX_ERROR = 4; // 0x4
+ field public static final int SSL_INVALID = 5; // 0x5
+ field public static final deprecated int SSL_MAX_ERROR = 6; // 0x6
field public static final int SSL_NOTYETVALID = 0; // 0x0
field public static final int SSL_UNTRUSTED = 3; // 0x3
}
diff --git a/core/java/android/net/http/SslError.java b/core/java/android/net/http/SslError.java
index 1e1cb49dabad..08c669232c5d 100644
--- a/core/java/android/net/http/SslError.java
+++ b/core/java/android/net/http/SslError.java
@@ -30,7 +30,7 @@ public class SslError {
/**
* The certificate is not yet valid
*/
- public static final int SSL_NOTYETVALID = 0;
+ public static final int SSL_NOTYETVALID = 0;
/**
* The certificate has expired
*/
@@ -43,12 +43,23 @@ public class SslError {
* The certificate authority is not trusted
*/
public static final int SSL_UNTRUSTED = 3;
+ /**
+ * The date of the certificate is invalid
+ */
+ public static final int SSL_DATE_INVALID = 4;
+ /**
+ * The certificate is invalid
+ */
+ public static final int SSL_INVALID = 5;
/**
* The number of different SSL errors (update if you add a new SSL error!!!)
+ * @deprecated This constant is not necessary for using the SslError API and
+ * can change from release to release.
*/
- public static final int SSL_MAX_ERROR = 4;
+ @Deprecated
+ public static final int SSL_MAX_ERROR = 6;
/**
* The SSL error set bitfield (each individual error is an bit index;
@@ -117,6 +128,30 @@ public class SslError {
}
/**
+ * Creates an SslError object from a chromium error code.
+ * @param error The chromium error code
+ * @param certificate The associated SSL certificate
+ * @param url The associated URL.
+ * @hide chromium error codes only available inside the framework
+ */
+ public static SslError SslErrorFromChromiumErrorCode(
+ int error, SslCertificate cert, String url) {
+ // The chromium error codes are in:
+ // external/chromium/net/base/net_error_list.h
+ if (error > -200 || error < -299) {
+ throw new NullPointerException("Not a valid chromium SSL error code.");
+ }
+ if (error == -200)
+ return new SslError(SSL_IDMISMATCH, cert, url);
+ if (error == -201)
+ return new SslError(SSL_DATE_INVALID, cert, url);
+ if (error == -202)
+ return new SslError(SSL_UNTRUSTED, cert, url);
+ // Map all other errors to SSL_INVALID
+ return new SslError(SSL_INVALID, cert, url);
+ }
+
+ /**
* Creates a new SSL error set object
* @param error The SSL error
* @param certificate The associated SSL certificate