diff options
| author | Kristian Monsen <kristianm@google.com> | 2011-07-28 06:50:40 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-28 06:50:40 -0700 |
| commit | 77d739006a38e765e236eb0828b9560effef15d6 (patch) | |
| tree | 9ef431d355d006acd73e1ddfd81589549a02922e /core/java/android | |
| parent | 2043b01b207aae3458da395bc6d501d76e59425c (diff) | |
| parent | 1abd5b3e6f11ef9d7076685c56ef942fa0dd77e4 (diff) | |
Merge "Part of fix for bug 4997380: Some error types unknown to SslError"
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/net/http/SslError.java | 39 |
1 files changed, 37 insertions, 2 deletions
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 |
