| Index: android_webview/java/src/org/chromium/android_webview/SslUtil.java
|
| diff --git a/android_webview/java/src/org/chromium/android_webview/SslUtil.java b/android_webview/java/src/org/chromium/android_webview/SslUtil.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..daa39584b7102bb2162bc2a3b261b0953a01843b
|
| --- /dev/null
|
| +++ b/android_webview/java/src/org/chromium/android_webview/SslUtil.java
|
| @@ -0,0 +1,41 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.android_webview;
|
| +
|
| +import android.net.http.SslCertificate;
|
| +import android.util.Log;
|
| +
|
| +import org.chromium.net.X509Util;
|
| +
|
| +import java.security.KeyStoreException;
|
| +import java.security.NoSuchAlgorithmException;
|
| +import java.security.cert.CertificateException;
|
| +import java.security.cert.X509Certificate;
|
| +
|
| +public class SslUtil {
|
| + private static final String TAG = SslUtil.class.getSimpleName();
|
| +
|
| + public static SslCertificate getCertificateFromDerBytes(byte[] derBytes) {
|
| + if (derBytes == null) {
|
| + return null;
|
| + }
|
| +
|
| + try {
|
| + X509Certificate x509Certificate =
|
| + X509Util.createCertificateFromBytes(derBytes);
|
| + return new SslCertificate(x509Certificate);
|
| + } catch (CertificateException e) {
|
| + // A SSL related exception must have occured. This shouldn't happen.
|
| + Log.w(TAG, "Could not read certificate: " + e);
|
| + } catch (KeyStoreException e) {
|
| + // A SSL related exception must have occured. This shouldn't happen.
|
| + Log.w(TAG, "Could not read certificate: " + e);
|
| + } catch (NoSuchAlgorithmException e) {
|
| + // A SSL related exception must have occured. This shouldn't happen.
|
| + Log.w(TAG, "Could not read certificate: " + e);
|
| + }
|
| + return null;
|
| + }
|
| +}
|
|
|