Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: net/test/android/javatests/src/org/chromium/net/test/util/CertTestUtil.java

Issue 2043803003: 👔 Reland #2: Move side-loaded test data /sdcard -> /sdcard/gtestdata (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase atop https://codereview.chromium.org/2041723006 Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.net.test.util; 5 package org.chromium.net.test.util;
6 6
7 import android.util.Base64; 7 import android.util.Base64;
8 8
9 import org.chromium.base.PathUtils; 9 import org.chromium.base.test.util.UrlUtils;
10 10
11 import java.io.BufferedReader; 11 import java.io.BufferedReader;
12 import java.io.FileReader; 12 import java.io.FileReader;
13 import java.io.IOException; 13 import java.io.IOException;
14 import java.security.MessageDigest; 14 import java.security.MessageDigest;
15 import java.security.NoSuchAlgorithmException; 15 import java.security.NoSuchAlgorithmException;
16 import java.security.cert.Certificate; 16 import java.security.cert.Certificate;
17 17
18 /** 18 /**
19 * Certificate related utility methods. 19 * Certificate related utility methods.
20 */ 20 */
21 public class CertTestUtil { 21 public class CertTestUtil {
22 /** 22 /**
23 * The location of the directory that contains certificates for testing. 23 * The location of the directory that contains certificates for testing.
24 */ 24 */
25 public static final String CERTS_DIRECTORY = 25 public static final String CERTS_DIRECTORY =
26 PathUtils.getExternalStorageDirectory() + "/net/data/ssl/certificate s/"; 26 UrlUtils.getIsolatedTestFilePath("net/data/ssl/certificates/");
27 27
28 private static final String BEGIN_MARKER = "-----BEGIN CERTIFICATE-----"; 28 private static final String BEGIN_MARKER = "-----BEGIN CERTIFICATE-----";
29 private static final String END_MARKER = "-----END CERTIFICATE-----"; 29 private static final String END_MARKER = "-----END CERTIFICATE-----";
30 30
31 private CertTestUtil() {} 31 private CertTestUtil() {}
32 32
33 /** 33 /**
34 * Converts a PEM formatted cert in a given file to the binary DER format. 34 * Converts a PEM formatted cert in a given file to the binary DER format.
35 * 35 *
36 * @param pemPathname the location of the certificate to convert. 36 * @param pemPathname the location of the certificate to convert.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 try { 68 try {
69 byte[] publicKey = cert.getPublicKey().getEncoded(); 69 byte[] publicKey = cert.getPublicKey().getEncoded();
70 MessageDigest digest = MessageDigest.getInstance("SHA-256"); 70 MessageDigest digest = MessageDigest.getInstance("SHA-256");
71 return digest.digest(publicKey); 71 return digest.digest(publicKey);
72 } catch (NoSuchAlgorithmException ex) { 72 } catch (NoSuchAlgorithmException ex) {
73 // This exception should never happen since SHA-256 is known algorit hm 73 // This exception should never happen since SHA-256 is known algorit hm
74 throw new RuntimeException(ex); 74 throw new RuntimeException(ex);
75 } 75 }
76 } 76 }
77 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698