From cfcb7ad5b68ad854ddbfe5ca1afcf85a1bb61f68 Mon Sep 17 00:00:00 2001 From: Narayan Kamath Date: Mon, 15 Jun 2015 11:27:26 +0100 Subject: Fix CertificateTest#testVerifyPublicKeyString2 Use a provider that can handle the provided public-key. bug: 21816913 Change-Id: Iee7a932a8767c4c1b781636dfb9456a1b604532f --- .../test/java/tests/security/cert/CertificateTest.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'luni/src') diff --git a/luni/src/test/java/tests/security/cert/CertificateTest.java b/luni/src/test/java/tests/security/cert/CertificateTest.java index d13e16b..194bfdb 100644 --- a/luni/src/test/java/tests/security/cert/CertificateTest.java +++ b/luni/src/test/java/tests/security/cert/CertificateTest.java @@ -300,17 +300,10 @@ public class MyModifiablePublicKey implements PublicKey { private Certificate cert; - private Provider wrongProvider; - - private Provider usefulProvider; - public void setUp() throws Exception { super.setUp(); TestUtils.initCertPathSSCertChain(); cert = TestUtils.rootCertificateSS; - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - wrongProvider = cf.getProvider(); - usefulProvider = Signature.getInstance("SHA1WithRSA").getProvider(); } /** @@ -326,8 +319,11 @@ public class MyModifiablePublicKey implements PublicKey { CertificateException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException { + final Signature sig = Signature.getInstance("SHA1WithRSA"); + sig.initVerify(cert.getPublicKey()); + final Provider provider = sig.getProvider(); // real test - cert.verify(cert.getPublicKey(), usefulProvider.getName()); + cert.verify(cert.getPublicKey(), provider.getName()); // Exception tests @@ -342,6 +338,9 @@ public class MyModifiablePublicKey implements PublicKey { // a new provider, test if it works, then remove it and test if the // exception is thrown. // + // CertificateFactory cf = CertificateFactory.getInstance("X.509"); + // Provider wrongProvider = cf.getProvider(); + // // Security.removeProvider(wrongProvider.getName()); // // try { -- cgit v1.1