jruby-openssl 0.5 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jruby-openssl might be problematic. Click here for more details.

@@ -1,3 +1,8 @@
1
+ == 0.5.1
2
+
3
+ * Multiple fixes by Brice Figureau to get net/ssh working. Requires JRuby 1.3.1 to be 100%
4
+ * Fix by Frederic Jean for a character-decoding issue for some certificates
5
+
1
6
  == 0.5
2
7
 
3
8
  * Fixed JRUBY-3614: Unsupported HMAC algorithm (HMACSHA-256)
Binary file
@@ -1,5 +1,5 @@
1
1
  module Jopenssl
2
2
  module Version
3
- VERSION = "0.5"
3
+ VERSION = "0.5.1"
4
4
  end
5
5
  end
@@ -19,6 +19,7 @@ class OpenSSL::TestCipher < Test::Unit::TestCase
19
19
  @c2 = OpenSSL::Cipher::DES.new(:EDE3, "CBC")
20
20
  @key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
21
21
  @iv = "\0\0\0\0\0\0\0\0"
22
+ @iv1 = "\1\1\1\1\1\1\1\1"
22
23
  @hexkey = "0000000000000000000000000000000000000000000000"
23
24
  @hexiv = "0000000000000000"
24
25
  @data = "DATA"
@@ -70,6 +71,21 @@ class OpenSSL::TestCipher < Test::Unit::TestCase
70
71
  assert_equal(s1, s2, "encrypt reset")
71
72
  end
72
73
 
74
+ def test_set_iv
75
+ @c1.encrypt
76
+ @c1.key = @key
77
+ @c1.iv = @iv
78
+ s1 = @c1.update(@data) + @c1.final
79
+ @c1.iv = @iv1
80
+ s1 += @c1.update(@data) + @c1.final
81
+ @c1.reset
82
+ @c1.iv = @iv
83
+ s2 = @c1.update(@data) + @c1.final
84
+ @c1.iv = @iv1
85
+ s2 += @c1.update(@data) + @c1.final
86
+ assert_equal(s1, s2, "encrypt reset")
87
+ end
88
+
73
89
  def test_empty_data
74
90
  @c1.encrypt
75
91
  assert_raises(ArgumentError){ @c1.update("") }
@@ -169,6 +169,68 @@ class OpenSSL::TestX509Certificate < Test::Unit::TestCase
169
169
  nil, nil, OpenSSL::Digest::SHA1.new)
170
170
  }
171
171
  end
172
+
173
+ def test_check_private_key
174
+ cert = issue_cert(@ca, @rsa2048, 1, Time.now, Time.now+3600, [],
175
+ nil, nil, OpenSSL::Digest::SHA1.new)
176
+ assert_equal(true, cert.check_private_key(@rsa2048))
177
+ end
178
+
179
+ def test_to_text
180
+ cert_pem = <<END
181
+ -----BEGIN CERTIFICATE-----
182
+ MIIC8zCCAdugAwIBAgIBATANBgkqhkiG9w0BAQQFADA9MRMwEQYKCZImiZPyLGQB
183
+ GRYDb3JnMRkwFwYKCZImiZPyLGQBGRYJcnVieS1sYW5nMQswCQYDVQQDDAJDQTAe
184
+ Fw0wOTA1MjMxNTAzNDNaFw0wOTA1MjMxNjAzNDNaMD0xEzARBgoJkiaJk/IsZAEZ
185
+ FgNvcmcxGTAXBgoJkiaJk/IsZAEZFglydWJ5LWxhbmcxCzAJBgNVBAMMAkNBMIIB
186
+ IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuV9ht9J7k4NBs38jOXvvTKY9
187
+ gW8nLICSno5EETR1cuF7i4pNs9I1QJGAFAX0BEO4KbzXmuOvfCpD3CU+Slp1enen
188
+ fzq/t/e/1IRW0wkJUJUFQign4CtrkJL+P07yx18UjyPlBXb81ApEmAB5mrJVSrWm
189
+ qbjs07JbuS4QQGGXLc+Su96DkYKmSNVjBiLxVVSpyZfAY3hD37d60uG+X8xdW5v6
190
+ 8JkRFIhdGlb6JL8fllf/A/blNwdJOhVr9mESHhwGjwfSeTDPfd8ZLE027E5lyAVX
191
+ 9KZYcU00mOX+fdxOSnGqS/8JDRh0EPHDL15RcJjV2J6vZjPb0rOYGDoMcH+94wID
192
+ AQABMA0GCSqGSIb3DQEBBAUAA4IBAQB8UTw1agA9wdXxHMUACduYu6oNL7pdF0dr
193
+ w7a4QPJyj62h4+Umxvp13q0PBw0E+mSjhXMcqUhDLjrmMcvvNGhuh5Sdjbe3GI/M
194
+ 3lCC9OwYYIzzul7omvGC3JEIGfzzdNnPPCPKEWp5X9f0MKLMR79qOf+sjHTjN2BY
195
+ SY3YGsEFxyTXDdqrlaYaOtTAdi/C+g1WxR8fkPLefymVwIFwvyc9/bnp7iBn7Hcw
196
+ mbxtLPbtQ9mURT0GHewZRTGJ1aiTq9Ag3xXME2FPF04eFRd3mclOQZNXKQ+LDxYf
197
+ k0X5FeZvsWf4srFxoVxlcDdJtHh91ZRpDDJYGQlsUm9CPTnO+e4E
198
+ -----END CERTIFICATE-----
199
+ END
200
+
201
+ cert = OpenSSL::X509::Certificate.new(cert_pem)
202
+
203
+ cert_text = <<END
204
+ [0] Version: 3
205
+ SerialNumber: 1
206
+ IssuerDN: DC=org,DC=ruby-lang,CN=CA
207
+ Start Date: Sat May 23 17:03:43 CEST 2009
208
+ Final Date: Sat May 23 18:03:43 CEST 2009
209
+ SubjectDN: DC=org,DC=ruby-lang,CN=CA
210
+ Public Key: RSA Public Key
211
+ modulus: b95f61b7d27b938341b37f23397bef4ca63d816f272c80929e8e4411347572e17b8b8a4db3d2354091801405f40443b829bcd79ae3af7c2a43dc253e4a5a757a77a77f3abfb7f7bfd48456d30909509505422827e02b6b9092fe3f4ef2c75f148f23e50576fcd40a449800799ab2554ab5a6a9b8ecd3b25bb92e104061972dcf92bbde839182a648d5630622f15554a9c997c0637843dfb77ad2e1be5fcc5d5b9bfaf0991114885d1a56fa24bf1f9657ff03f6e53707493a156bf661121e1c068f07d27930cf7ddf192c4d36ec4e65c80557f4a658714d3498e5fe7ddc4e4a71aa4bff090d187410f1c32f5e517098d5d89eaf6633dbd2b398183a0c707fbde3
212
+ public exponent: 10001
213
+
214
+ Signature Algorithm: MD5withRSA
215
+ Signature: 7c513c356a003dc1d5f11cc50009db98bbaa0d2f
216
+ ba5d17476bc3b6b840f2728fada1e3e526c6fa75
217
+ dead0f070d04fa64a385731ca948432e3ae631cb
218
+ ef34686e87949d8db7b7188fccde5082f4ec1860
219
+ 8cf3ba5ee89af182dc910819fcf374d9cf3c23ca
220
+ 116a795fd7f430a2cc47bf6a39ffac8c74e33760
221
+ 58498dd81ac105c724d70ddaab95a61a3ad4c076
222
+ 2fc2fa0d56c51f1f90f2de7f2995c08170bf273d
223
+ fdb9e9ee2067ec773099bc6d2cf6ed43d994453d
224
+ 061dec19453189d5a893abd020df15cc13614f17
225
+ 4e1e15177799c94e419357290f8b0f161f9345f9
226
+ 15e66fb167f8b2b171a15c65703749b4787dd594
227
+ 690c325819096c526f423d39cef9ee04
228
+ END
229
+ assert_not_nil(cert.to_text)
230
+ # This is commented out because it doesn't take timezone into consideration; FIXME
231
+ #assert_equal(cert_text, cert.to_text)
232
+ end
233
+
172
234
  end
173
235
 
174
236
  end
@@ -213,6 +213,22 @@ class OpenSSL::TestX509CRL < Test::Unit::TestCase
213
213
  crl.version = 0
214
214
  assert_equal(false, crl.verify(@dsa512))
215
215
  end
216
+
217
+ def test_create_from_pem
218
+ crl = <<END
219
+ -----BEGIN X509 CRL-----
220
+ MIHkME8CAQEwDQYJKoZIhvcNAQEFBQAwDTELMAkGA1UEAwwCY2EXDTA5MDUyMzEw
221
+ MTkyM1oXDTE0MDUyMjEwMTkyM1qgDjAMMAoGA1UdFAQDAgEAMA0GCSqGSIb3DQEB
222
+ BQUAA4GBAGrGXN03TQdoluA5Xjv64We9EOvmE0EviKMeaZ/n8krEwFhUK7Yq3GVD
223
+ BFrb40cdFX1433buCZHG7Tq7eGv8cG1eO5RasuiedurMQXmVRDTDjGor/58Dk/Wy
224
+ owO/GR8ASm6Fx6AUKEgLAaoaaptpaWtEB+N4uaGvc0LFO9WY+ZMq
225
+ -----END X509 CRL-----
226
+ END
227
+ crl = OpenSSL::X509::CRL.new(crl)
228
+ assert_equal(1, crl.version)
229
+ assert_equal(OpenSSL::X509::Name.parse("/CN=ca").to_der, crl.issuer.to_der)
230
+ end
231
+
216
232
  end
217
233
 
218
234
  end
@@ -135,6 +135,44 @@ class OpenSSL::TestX509Request < Test::Unit::TestCase
135
135
  assert_raise(OpenSSL::X509::RequestError){
136
136
  issue_csr(0, @dn, @dsa512, OpenSSL::Digest::MD5.new) }
137
137
  end
138
+
139
+ def test_create_from_pem
140
+ req = <<END
141
+ -----BEGIN CERTIFICATE REQUEST-----
142
+ MIIBVTCBvwIBADAWMRQwEgYDVQQDDAsxOTIuMTY4LjAuNDCBnzANBgkqhkiG9w0B
143
+ AQEFAAOBjQAwgYkCgYEA0oTTzFLydOTVtBpNdYl4S0356AysVkHlqD/tNEMxQT0l
144
+ dXdNoDKb/3TfM5WMciNxBb8rImJ51vEIf6WaWvPbaawcmhNWA9JmhMIeFCdeXyu/
145
+ XEjiiEOL4MkWf6qfsu6VoPr2YSnR0iiWLgWcnRPuy84+PE1XPPl1qGDA0apWJ9kC
146
+ AwEAAaAAMA0GCSqGSIb3DQEBBAUAA4GBAKdlyDzVrXRLkPdukQUTTy6uwhv35SKL
147
+ FfiKDrHtnFYd7VbynQ1sRre5CknuRrm+E7aEJEwpz6MS+6nqmQ6JwGcm/hlZM/m7
148
+ DVD201pI3p6LIxaRyXE20RYTp0Jj6jv+tNFd0wjVlzgStmcplNo8hu6Dtp1gKETW
149
+ qL7M4i48FXHn
150
+ -----END CERTIFICATE REQUEST-----
151
+ END
152
+ req = OpenSSL::X509::Request.new(req)
153
+
154
+ assert_equal(0, req.version)
155
+ assert_equal(OpenSSL::X509::Name.parse("/CN=192.168.0.4").to_der, req.subject.to_der)
156
+ end
157
+
158
+ def test_create_to_pem
159
+ req_s = <<END
160
+ -----BEGIN CERTIFICATE REQUEST-----
161
+ MIIBVTCBvwIBADAWMRQwEgYDVQQDDAsxOTIuMTY4LjAuNDCBnzANBgkqhkiG9w0B
162
+ AQEFAAOBjQAwgYkCgYEA0oTTzFLydOTVtBpNdYl4S0356AysVkHlqD/tNEMxQT0l
163
+ dXdNoDKb/3TfM5WMciNxBb8rImJ51vEIf6WaWvPbaawcmhNWA9JmhMIeFCdeXyu/
164
+ XEjiiEOL4MkWf6qfsu6VoPr2YSnR0iiWLgWcnRPuy84+PE1XPPl1qGDA0apWJ9kC
165
+ AwEAAaAAMA0GCSqGSIb3DQEBBAUAA4GBAKdlyDzVrXRLkPdukQUTTy6uwhv35SKL
166
+ FfiKDrHtnFYd7VbynQ1sRre5CknuRrm+E7aEJEwpz6MS+6nqmQ6JwGcm/hlZM/m7
167
+ DVD201pI3p6LIxaRyXE20RYTp0Jj6jv+tNFd0wjVlzgStmcplNo8hu6Dtp1gKETW
168
+ qL7M4i48FXHn
169
+ -----END CERTIFICATE REQUEST-----
170
+ END
171
+ req = OpenSSL::X509::Request.new(req_s)
172
+
173
+ assert_equal(req_s, req.to_pem)
174
+ end
175
+
138
176
  end
139
177
 
140
178
  end
@@ -4,6 +4,7 @@ begin
4
4
  rescue LoadError
5
5
  end
6
6
  require "test/unit"
7
+ require "tempfile"
7
8
 
8
9
  if defined?(OpenSSL)
9
10
 
@@ -212,6 +213,33 @@ class OpenSSL::TestX509Store < Test::Unit::TestCase
212
213
  store.add_crl(crl2) # add CRL issued by same CA twice.
213
214
  }
214
215
  end
216
+
217
+ def test_add_file
218
+ ca1_cert = <<END
219
+ -----BEGIN CERTIFICATE-----
220
+ MIIBzzCCATigAwIBAgIBATANBgkqhkiG9w0BAQUFADANMQswCQYDVQQDDAJjYTAe
221
+ Fw0wOTA1MjIxMDE5MjNaFw0xNDA1MjExMDE5MjNaMA0xCzAJBgNVBAMMAmNhMIGf
222
+ MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDcTL520vsbXHXPfkHKrcgWbk2zVf0y
223
+ oK7bPg06kjCghs8KYsi9b/tT9KpkpejD0KucDBSmDILD3PvIWrNFcBRWf6ZC5vA5
224
+ YuF6ueATuFhsXjUFuNLqyPcIX+XrOQmXgjiyO9nc5vzQwWRRhdyyT8DgCRUD/yHW
225
+ pjD2ZEGIAVLY/wIDAQABoz8wPTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQf
226
+ 923P/SgiCcbiN20bbmuFM6SLxzALBgNVHQ8EBAMCAQYwDQYJKoZIhvcNAQEFBQAD
227
+ gYEAE0CpCo8MxhfUNWMHF5GsGEG2+1LdE+aUX7gSb6d4vn1WjusrM2FoOFTomt32
228
+ YPqJwMEbcqILq2v9Kkao4QNJRlK+z1xpRDnt1iBrHdXrYJFvYnfMqv3z7XAFPfQZ
229
+ yMP+P2sR0jPzy4UNZfDIMmMUqQdhkz7onKWOGjXwLEtkCMs=
230
+ -----END CERTIFICATE-----
231
+ END
232
+
233
+ f = Tempfile.new("ca1_cert")
234
+ f << ca1_cert
235
+ f.close
236
+
237
+ store = OpenSSL::X509::Store.new
238
+ store.add_file(f.path)
239
+ assert_equal(true, store.verify(OpenSSL::X509::Certificate.new(ca1_cert)))
240
+ f.unlink
241
+ end
242
+
215
243
  end
216
244
 
217
245
  end
metadata CHANGED
@@ -5,9 +5,9 @@ homepage: http://jruby-extras.rubyforge.org/jruby-openssl
5
5
  executables: []
6
6
 
7
7
  version: !ruby/object:Gem::Version
8
- version: "0.5"
8
+ version: 0.5.1
9
9
  post_install_message:
10
- date: 2009-05-12 05:00:00 +00:00
10
+ date: 2009-06-15 05:00:00 +00:00
11
11
  files:
12
12
  - History.txt
13
13
  - README.txt