summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2013-05-03 10:14:38 -0700
committerKenny Root <kroot@google.com>2013-05-03 10:14:43 -0700
commitd2cbcf1c2e2169d6454ede8ac7d1cfc73860b9ae (patch)
treecb8d85428f51a9ab80ae87864e2b8b5c9e1106b0
parent4f5a23794efbb123751239c66917ecae43c936be (diff)
downloadlibcore-d2cbcf1c2e2169d6454ede8ac7d1cfc73860b9ae.zip
libcore-d2cbcf1c2e2169d6454ede8ac7d1cfc73860b9ae.tar.gz
libcore-d2cbcf1c2e2169d6454ede8ac7d1cfc73860b9ae.tar.bz2
Move encoding method out of NativeCrypto
Move the encoding method for X.509 out of NativeCrypto to the class that uses it. Change-Id: I57198101553f309c04b5e757716d1d807eb99a90
-rw-r--r--crypto/src/main/java/org/conscrypt/NativeCrypto.java10
-rw-r--r--crypto/src/main/java/org/conscrypt/OpenSSLSocketImpl.java11
2 files changed, 10 insertions, 11 deletions
diff --git a/crypto/src/main/java/org/conscrypt/NativeCrypto.java b/crypto/src/main/java/org/conscrypt/NativeCrypto.java
index 18bab4c..1416d1b 100644
--- a/crypto/src/main/java/org/conscrypt/NativeCrypto.java
+++ b/crypto/src/main/java/org/conscrypt/NativeCrypto.java
@@ -29,7 +29,6 @@ import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateParsingException;
-import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
@@ -810,15 +809,6 @@ public final class NativeCrypto {
public static native void SSL_check_private_key(long ssl) throws SSLException;
- public static byte[][] encodeIssuerX509Principals(X509Certificate[] certificates)
- throws CertificateEncodingException {
- byte[][] principalBytes = new byte[certificates.length][];
- for (int i = 0; i < certificates.length; i++) {
- principalBytes[i] = certificates[i].getIssuerX500Principal().getEncoded();
- }
- return principalBytes;
- }
-
public static native void SSL_set_client_CA_list(long ssl, byte[][] asn1DerEncodedX500Principals);
public static native long SSL_get_mode(long ssl);
diff --git a/crypto/src/main/java/org/conscrypt/OpenSSLSocketImpl.java b/crypto/src/main/java/org/conscrypt/OpenSSLSocketImpl.java
index 70ac554..3301387 100644
--- a/crypto/src/main/java/org/conscrypt/OpenSSLSocketImpl.java
+++ b/crypto/src/main/java/org/conscrypt/OpenSSLSocketImpl.java
@@ -362,7 +362,7 @@ public class OpenSSLSocketImpl
if (issuers != null && issuers.length != 0) {
byte[][] issuersBytes;
try {
- issuersBytes = NativeCrypto.encodeIssuerX509Principals(issuers);
+ issuersBytes = encodeIssuerX509Principals(issuers);
} catch (CertificateEncodingException e) {
throw new IOException("Problem encoding principals", e);
}
@@ -445,6 +445,15 @@ public class OpenSSLSocketImpl
}
}
+ private static byte[][] encodeIssuerX509Principals(X509Certificate[] certificates)
+ throws CertificateEncodingException {
+ byte[][] principalBytes = new byte[certificates.length][];
+ for (int i = 0; i < certificates.length; i++) {
+ principalBytes[i] = certificates[i].getIssuerX500Principal().getEncoded();
+ }
+ return principalBytes;
+ }
+
String getPeerHostName() {
if (wrappedHost != null) {
return wrappedHost;