Skip to content

Commit

Permalink
Merge pull request #29 from Sere-Fu/remove_bc
Browse files Browse the repository at this point in the history
  • Loading branch information
Sere-Fu committed Apr 10, 2023
2 parents 0d99b71 + 149b669 commit 1bec328
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
6 changes: 5 additions & 1 deletion common/src/main/java/org/conscrypt/ConscryptEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,11 @@ public void verifyCertificateChain(byte[][] certChain, String authMethod)
if (certChain == null || certChain.length == 0) {
throw new CertificateException("Peer sent no certificate");
}
X509Certificate[] peerCertChain = SSLUtils.decodeX509CertificateChain(certChain);
int numCerts = certChain.length;
X509Certificate[] peerCertChain = new X509Certificate[numCerts];
for (int i=0; i<numCerts; i++) {
peerCertChain[i] = OpenSSLX509Certificate.fromX509Der(certChain[i]);
}

X509TrustManager x509tm = sslParameters.getX509TrustManager();
if (x509tm == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,10 @@ private PublicKey getSM2PublicKey(byte[] encoded) {
OpenSSLKey pkey = new OpenSSLKey(NativeCrypto.X509_get_pubkey(mContext, this));
final int pkeyType = NativeCrypto.EVP_PKEY_type(pkey.getNativeRef());
if (pkeyType == NativeConstants.EVP_PKEY_SM2) {
return new X509PublicKey("SM2", encoded);
KeyFactory kf = KeyFactory.getInstance("SM2");
return kf.generatePublic(new X509EncodedKeySpec(encoded));
}
} catch (NoSuchAlgorithmException | InvalidKeyException ignored) {
} catch (NoSuchAlgorithmException | InvalidKeyException | InvalidKeySpecException ignored) {
// Ignored
}
return null;
Expand Down
4 changes: 1 addition & 3 deletions common/src/main/java/org/conscrypt/SSLUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.security.cert.CertificateException;

import org.bouncycastle.jce.provider.BouncyCastleProvider;

/**
* Utility methods for SSL packet processing. Copied from the Netty project.
* <p>
Expand Down Expand Up @@ -196,7 +194,7 @@ static X509Certificate[] decodeX509CertificateChain(byte[][] certChain)

private static CertificateFactory getCertificateFactory() {
try {
return CertificateFactory.getInstance("X.509",new BouncyCastleProvider());
return CertificateFactory.getInstance("X.509");
} catch (java.security.cert.CertificateException e) {
return null;
}
Expand Down
4 changes: 0 additions & 4 deletions openjdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,6 @@ dependencies {
testRuntimeClasspath sourceSets["$preferredSourceSet"].output

platformCompileOnly sourceSets.main.output

compile libraries.bouncycastle_apis,
libraries.bouncycastle_provider
}

nativeClassifiers.each { nativeClassifier ->
Expand Down Expand Up @@ -479,4 +476,3 @@ static String classifierFor(osName, archName) {
static String sourceSetName(classifier) {
classifier.replaceAll("-", "_")
}

0 comments on commit 1bec328

Please sign in to comment.