Skip to content

Commit 3518d8e

Browse files
committed
[refactor] adjust/add exception debugging
1 parent 8b4b769 commit 3518d8e

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

src/main/java/org/jruby/ext/openssl/X509Cert.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -670,23 +670,15 @@ public RubyBoolean verify(final IRubyObject key) {
670670
return runtime.getTrue();
671671
}
672672
catch (CertificateException e) {
673-
debugStackTrace(runtime, "Certificate#verify failed", e);
673+
debugStackTrace(runtime, "X509Cert#verify", e);
674674
throw newCertificateError(runtime, e);
675675
}
676-
catch (NoSuchAlgorithmException e) {
676+
catch (NoSuchProviderException|NoSuchAlgorithmException e) {
677677
debugStackTrace(runtime, e);
678678
throw newCertificateError(runtime, e);
679679
}
680-
catch (NoSuchProviderException e) {
681-
debugStackTrace(runtime, e);
682-
throw newCertificateError(runtime, e);
683-
}
684-
catch (SignatureException e) {
685-
debug(runtime, "Certificate#verify failed", e);
686-
return runtime.getFalse();
687-
}
688-
catch (InvalidKeyException e) {
689-
debug(runtime, "Certificate#verify failed", e);
680+
catch (SignatureException|InvalidKeyException e) {
681+
debug(runtime, "X509Cert#verify failed", e);
690682
return runtime.getFalse();
691683
}
692684
}

src/main/java/org/jruby/ext/openssl/X509Request.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ public IRubyObject set_public_key(final IRubyObject pkey) {
309309
@JRubyMethod
310310
public IRubyObject sign(final ThreadContext context,
311311
final IRubyObject key, final IRubyObject digest) {
312-
// PublicKey publicKey = public_key.getPublicKey();
313312
PrivateKey privateKey = ((PKey) key).getPrivateKey();
314313

315314
final Ruby runtime = context.runtime;
@@ -319,14 +318,14 @@ public IRubyObject sign(final ThreadContext context,
319318
try {
320319
request = null; getRequest().sign( privateKey, digAlg );
321320
}
322-
catch (GeneralSecurityException e) {
323-
debugStackTrace(runtime, e);
321+
catch (InvalidKeyException e) {
322+
debug(runtime, "X509Request#sign failed", e);
323+
throw newRequestError(runtime, e);
324+
}
325+
catch (Exception e) {
326+
debugStackTrace(runtime, "X509Request#sign", e);
324327
throw newRequestError(runtime, e);
325328
}
326-
//catch (IOException e) {
327-
// debugStackTrace(runtime, e);
328-
// throw newRequestError(runtime, e);
329-
//}
330329
return this;
331330
}
332331

0 commit comments

Comments
 (0)