Title: [805] trunk/jopenssl/src/java/org/jruby/ext/openssl/X509Cert.java:
Fix for JRUBY-1314, patch by Egglestone
- Revision
- 805
- Author
- olabini
- Date
- 2007-11-28 07:33:58 -0500 (Wed, 28 Nov 2007)
Log Message
Fix for JRUBY-1314, patch by Egglestone
Modified Paths
Diff
Modified: trunk/jopenssl/src/java/org/jruby/ext/openssl/X509Cert.java (804 => 805)
--- trunk/jopenssl/src/java/org/jruby/ext/openssl/X509Cert.java 2007-11-22 13:48:44 UTC (rev 804)
+++ trunk/jopenssl/src/java/org/jruby/ext/openssl/X509Cert.java 2007-11-28 12:33:58 UTC (rev 805)
@@ -163,6 +163,15 @@
set_subject(((RubyModule)(getRuntime().getModule("OpenSSL").getConstant("X509"))).getConstant("Name").callMethod(tc,"new",RubyString.newString(getRuntime(), cert.getSubjectX500Principal().getEncoded())));
set_issuer(((RubyModule)(getRuntime().getModule("OpenSSL").getConstant("X509"))).getConstant("Name").callMethod(tc,"new",RubyString.newString(getRuntime(), cert.getIssuerX500Principal().getEncoded())));
+ String algorithm = cert.getPublicKey().getAlgorithm();
+ if ("RSA".equalsIgnoreCase(algorithm)) {
+ set_public_key(((RubyModule)(getRuntime().getModule("OpenSSL").getConstant("PKey"))).getConstant("RSA").callMethod(tc,"new",RubyString.newString(getRuntime(), cert.getPublicKey().getEncoded())));
+ } else if ("DSA".equalsIgnoreCase(algorithm)) {
+ set_public_key(((RubyModule)(getRuntime().getModule("OpenSSL").getConstant("PKey"))).getConstant("DSA").callMethod(tc,"new",RubyString.newString(getRuntime(), cert.getPublicKey().getEncoded())));
+ } else {
+ throw new RaiseException(getRuntime(), (RubyClass)(((RubyModule)(getRuntime().getModule("OpenSSL").getConstant("X509"))).getConstant("CertificateError")), "The algorithm " + algorithm + " is unsupported for public keys", true);
+ }
+
IRubyObject extFact = ((RubyClass)(((RubyModule)(getRuntime().getModule("OpenSSL").getConstant("X509"))).getConstant("ExtensionFactory"))).callMethod(tc,"new");
extFact.callMethod(tc,"subject_certificate=",this);
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel