提交 3b174829 编写于 作者: J juh

8005939: sun/security/x509/{X509CRLImplX509CertImpl}/Verify.java fail in...

8005939: sun/security/x509/{X509CRLImplX509CertImpl}/Verify.java fail in confusing way when some providers not present
Reviewed-by: mullan, weijun
上级 7b78dcc7
...@@ -95,7 +95,7 @@ public class Verify { ...@@ -95,7 +95,7 @@ public class Verify {
* Should fail with NoSuchAlgorithmException. * Should fail with NoSuchAlgorithmException.
*/ */
try { try {
verifyCRL(crlIssuerCertPubKey, "SunPCSC"); verifyCRL(crlIssuerCertPubKey, "SunJCE");
throw new RuntimeException("Didn't catch the exception properly"); throw new RuntimeException("Didn't catch the exception properly");
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
System.out.println("Caught the correct exception."); System.out.println("Caught the correct exception.");
...@@ -148,6 +148,10 @@ public class Verify { ...@@ -148,6 +148,10 @@ public class Verify {
throws CRLException, NoSuchAlgorithmException, InvalidKeyException, throws CRLException, NoSuchAlgorithmException, InvalidKeyException,
SignatureException { SignatureException {
Provider provider = Security.getProvider(providerName); Provider provider = Security.getProvider(providerName);
if (provider == null) {
throw new RuntimeException("Provider " + providerName
+ " not found.");
}
crl.verify(key, provider); crl.verify(key, provider);
} }
} }
...@@ -86,7 +86,7 @@ public class Verify { ...@@ -86,7 +86,7 @@ public class Verify {
* Should fail with NoSuchAlgorithmException. * Should fail with NoSuchAlgorithmException.
*/ */
try { try {
verifyCert(selfSignedCertPubKey, "SunPCSC"); verifyCert(selfSignedCertPubKey, "SunJCE");
throw new RuntimeException("Didn't catch the exception properly"); throw new RuntimeException("Didn't catch the exception properly");
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
System.out.println("Caught the correct exception."); System.out.println("Caught the correct exception.");
...@@ -134,6 +134,10 @@ public class Verify { ...@@ -134,6 +134,10 @@ public class Verify {
throws CertificateException, NoSuchAlgorithmException, throws CertificateException, NoSuchAlgorithmException,
InvalidKeyException, SignatureException { InvalidKeyException, SignatureException {
Provider provider = Security.getProvider(providerName); Provider provider = Security.getProvider(providerName);
if (provider == null) {
throw new RuntimeException("Provider " + providerName
+ " not found.");
}
cert.verify(key, provider); cert.verify(key, provider);
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册