jruby-openssl 0.6 → 0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +45 -0
- data/Manifest.txt +19 -11
- data/README.txt +1 -12
- data/Rakefile +12 -5
- data/lib/bcmail-jdk15-144.jar +0 -0
- data/lib/bcprov-jdk15-144.jar +0 -0
- data/lib/jopenssl/version.rb +1 -1
- data/lib/jopenssl.jar +0 -0
- data/lib/openssl/bn.rb +5 -3
- data/lib/openssl/buffering.rb +2 -2
- data/lib/openssl/cipher.rb +27 -18
- data/lib/openssl/digest.rb +19 -4
- data/lib/openssl/dummy.rb +11 -11
- data/lib/openssl/dummyssl.rb +2 -1
- data/lib/openssl/pkcs7.rb +25 -0
- data/lib/openssl/ssl.rb +70 -26
- data/lib/openssl/x509.rb +2 -2
- data/lib/openssl.rb +47 -2
- data/test/fixture/ca-bundle.crt +2794 -0
- data/test/fixture/keypair.pem +27 -0
- data/test/fixture/selfcert.pem +23 -0
- data/test/{pkcs7_mime_enveloped.message → java/pkcs7_mime_enveloped.message} +0 -0
- data/test/{pkcs7_mime_signed.message → java/pkcs7_mime_signed.message} +0 -0
- data/test/{pkcs7_multipart_signed.message → java/pkcs7_multipart_signed.message} +0 -0
- data/test/{test_java_attribute.rb → java/test_java_attribute.rb} +2 -2
- data/test/{test_java_bio.rb → java/test_java_bio.rb} +0 -0
- data/test/{test_java_mime.rb → java/test_java_mime.rb} +0 -0
- data/test/{test_java_pkcs7.rb → java/test_java_pkcs7.rb} +35 -32
- data/test/{test_java_smime.rb → java/test_java_smime.rb} +0 -0
- data/test/openssl/test_asn1.rb +1 -3
- data/test/openssl/test_cipher.rb +7 -10
- data/test/openssl/test_ec.rb +113 -0
- data/test/openssl/test_pair.rb +3 -8
- data/test/openssl/test_pkcs7.rb +339 -11
- data/test/openssl/test_ssl.rb +728 -100
- data/test/openssl/test_x509cert.rb +5 -5
- data/test/openssl/test_x509crl.rb +1 -2
- data/test/openssl/test_x509ext.rb +3 -3
- data/test/openssl/test_x509name.rb +1 -0
- data/test/openssl/test_x509req.rb +5 -7
- data/test/openssl/test_x509store.rb +3 -2
- data/test/test_all.rb +1 -0
- data/test/{test_openssl_x509.rb → test_certificate.rb} +33 -3
- data/test/test_cipher.rb +85 -7
- data/test/test_integration.rb +7 -8
- data/test/test_java.rb +9 -9
- data/test/test_openssl.rb +3 -33
- data/test/test_parse_certificate.rb +8 -1
- data/test/test_pkcs7.rb +40 -0
- data/test/test_pkey.rb +165 -7
- data/test/test_x509store.rb +8 -7
- metadata +31 -30
- data/lib/bcmail-jdk14-139.jar +0 -0
- data/lib/bcprov-jdk14-139.jar +0 -0
data/History.txt
CHANGED
@@ -1,3 +1,48 @@
|
|
1
|
+
== 0.7
|
2
|
+
|
3
|
+
- Follow MRI 1.8.7 openssl API changes
|
4
|
+
- Fixes so that jruby-openssl can run on appengine
|
5
|
+
- Many bug and compatibility fixes, see below.
|
6
|
+
- This is the last release that will be compatible with JRuby 1.4.x.
|
7
|
+
- Compatibility issues
|
8
|
+
-- JRUBY-4342: Follow ruby-openssl of CRuby 1.8.7.
|
9
|
+
-- JRUBY-4346: Sync tests with tests for ruby-openssl of CRuby 1.8.7.
|
10
|
+
-- JRUBY-4444: OpenSSL crash running RubyGems tests
|
11
|
+
-- JRUBY-4075: Net::SSH gives OpenSSL::Cipher::CipherError "No message available"
|
12
|
+
-- JRUBY-4076: Net::SSH padding error using 3des-cbc on Solaris
|
13
|
+
-- JRUBY-4541: jruby-openssl doesn't load on App Engine.
|
14
|
+
-- JRUBY-4077: Net::SSH "all authorization methods failed" Solaris -> Solaris
|
15
|
+
-- JRUBY-4535: Issues with the BouncyCastle provider
|
16
|
+
-- JRUBY-4510: JRuby-OpenSSL crashes when JCE fails a initialise bcprov
|
17
|
+
-- JRUBY-4343: Update BouncyCastle jar to upstream version; jdk14-139 -> jdk15-144
|
18
|
+
- Cipher issues
|
19
|
+
-- JRUBY-4012: Initialization vector length handled differently than in MRI (longer IV sequence are trimmed to fit the required)
|
20
|
+
-- JRUBY-4473: Implemented DSA key generation
|
21
|
+
-- JRUBY-4472: Cipher does not support RC4 and CAST
|
22
|
+
-- JRUBY-4577: InvalidParameterException 'Wrong keysize: must be equal to 112 or 168' for DES3 + SunJCE
|
23
|
+
- SSL and X.509(PKIX) issues
|
24
|
+
-- JRUBY-4384: TCP socket connection causes busy loop of SSL server
|
25
|
+
-- JRUBY-4370: Implement SSLContext#ciphers
|
26
|
+
-- JRUBY-4688: SSLContext#ciphers does not accept 'DEFAULT'
|
27
|
+
-- JRUBY-4357: SSLContext#{setup,ssl_version=} are not implemented
|
28
|
+
-- JRUBY-4397: SSLContext#extra_chain_cert and SSLContext#client_ca
|
29
|
+
-- JRUBY-4684: SSLContext#verify_depth is ignored
|
30
|
+
-- JRUBY-4398: SSLContext#options does not affect to SSL sessions
|
31
|
+
-- JRUBY-4360: Implement SSLSocket#verify_result and dependents
|
32
|
+
-- JRUBY-3829: SSLSocket#read should clear given buffer before concatenating (ByteBuffer.java:328:in `allocate': java.lang.IllegalArgumentException when returning SOAP queries over a certain size)
|
33
|
+
-- JRUBY-4686: SSLSocket can drop last chunk of data just before inbound channel close
|
34
|
+
-- JRUBY-4369: X509Store#verify_callback is not called
|
35
|
+
-- JRUBY-4409: OpenSSL::X509::Store#add_file corrupts when it includes certificates which have the same subject (problem with ruby-openid-apps-discovery (github jruby-openssl issue #2))
|
36
|
+
-- JRUBY-4333: PKCS#8 formatted privkey read
|
37
|
+
-- JRUBY-4454: Loading Key file as a Certificate causes NPE
|
38
|
+
-- JRUBY-4455: calling X509::Certificate#sign for the Certificate initialized from PEM causes IllegalStateException
|
39
|
+
- PKCS#7 issues
|
40
|
+
-- JRUBY-4379: PKCS7#sign failed for DES3 cipher algorithm
|
41
|
+
-- JRUBY-4428: Allow to use DES-EDE3-CBC in PKCS#7 w/o the Policy Files (rake test doesn't finish on JDK5 w/o policy files update)
|
42
|
+
- Misc
|
43
|
+
-- JRUBY-4574: jruby-openssl deprecation warning cleanup
|
44
|
+
-- JRUBY-4591: jruby-1.4 support
|
45
|
+
|
1
46
|
== 0.6
|
2
47
|
|
3
48
|
- This is a recommended upgrade to jruby-openssl. A security problem
|
data/Manifest.txt
CHANGED
@@ -4,8 +4,8 @@ Manifest.txt
|
|
4
4
|
README.txt
|
5
5
|
License.txt
|
6
6
|
lib/jopenssl.jar
|
7
|
-
lib/bcmail-
|
8
|
-
lib/bcprov-
|
7
|
+
lib/bcmail-jdk15-144.jar
|
8
|
+
lib/bcprov-jdk15-144.jar
|
9
9
|
lib/jopenssl
|
10
10
|
lib/jopenssl.jar
|
11
11
|
lib/openssl
|
@@ -17,36 +17,35 @@ lib/openssl/cipher.rb
|
|
17
17
|
lib/openssl/digest.rb
|
18
18
|
lib/openssl/dummy.rb
|
19
19
|
lib/openssl/dummyssl.rb
|
20
|
+
lib/openssl/pkcs7.rb
|
20
21
|
lib/openssl/ssl.rb
|
21
22
|
lib/openssl/x509.rb
|
22
23
|
test/cert_with_ec_pk.cer
|
23
24
|
test/fixture
|
25
|
+
test/java
|
24
26
|
test/openssl
|
25
|
-
test/pkcs7_mime_enveloped.message
|
26
|
-
test/pkcs7_mime_signed.message
|
27
|
-
test/pkcs7_multipart_signed.message
|
28
27
|
test/ref
|
28
|
+
test/test_all.rb
|
29
|
+
test/test_certificate.rb
|
29
30
|
test/test_cipher.rb
|
30
31
|
test/test_integration.rb
|
31
32
|
test/test_java.rb
|
32
|
-
test/test_java_attribute.rb
|
33
|
-
test/test_java_bio.rb
|
34
|
-
test/test_java_mime.rb
|
35
|
-
test/test_java_pkcs7.rb
|
36
|
-
test/test_java_smime.rb
|
37
33
|
test/test_openssl.rb
|
38
|
-
test/test_openssl_x509.rb
|
39
34
|
test/test_parse_certificate.rb
|
35
|
+
test/test_pkcs7.rb
|
40
36
|
test/test_pkey.rb
|
41
37
|
test/test_x509store.rb
|
42
38
|
test/ut_eof.rb
|
39
|
+
test/fixture/ca-bundle.crt
|
43
40
|
test/fixture/ca_path
|
44
41
|
test/fixture/cacert.pem
|
45
42
|
test/fixture/cert_localhost.pem
|
46
43
|
test/fixture/common.pem
|
44
|
+
test/fixture/keypair.pem
|
47
45
|
test/fixture/localhost_keypair.pem
|
48
46
|
test/fixture/max.pem
|
49
47
|
test/fixture/purpose
|
48
|
+
test/fixture/selfcert.pem
|
50
49
|
test/fixture/verisign.pem
|
51
50
|
test/fixture/verisign_c3.pem
|
52
51
|
test/fixture/ca_path/72fa7371.0
|
@@ -77,10 +76,19 @@ test/fixture/purpose/sslclient/sslclient.pem
|
|
77
76
|
test/fixture/purpose/sslserver/csr.pem
|
78
77
|
test/fixture/purpose/sslserver/keypair.pem
|
79
78
|
test/fixture/purpose/sslserver/sslserver.pem
|
79
|
+
test/java/pkcs7_mime_enveloped.message
|
80
|
+
test/java/pkcs7_mime_signed.message
|
81
|
+
test/java/pkcs7_multipart_signed.message
|
82
|
+
test/java/test_java_attribute.rb
|
83
|
+
test/java/test_java_bio.rb
|
84
|
+
test/java/test_java_mime.rb
|
85
|
+
test/java/test_java_pkcs7.rb
|
86
|
+
test/java/test_java_smime.rb
|
80
87
|
test/openssl/ssl_server.rb
|
81
88
|
test/openssl/test_asn1.rb
|
82
89
|
test/openssl/test_cipher.rb
|
83
90
|
test/openssl/test_digest.rb
|
91
|
+
test/openssl/test_ec.rb
|
84
92
|
test/openssl/test_hmac.rb
|
85
93
|
test/openssl/test_ns_spki.rb
|
86
94
|
test/openssl/test_pair.rb
|
data/README.txt
CHANGED
@@ -6,19 +6,8 @@
|
|
6
6
|
|
7
7
|
JRuby-OpenSSL is an add-on gem for JRuby that emulates the Ruby OpenSSL native library.
|
8
8
|
|
9
|
-
JRuby offers *just enough* compatibility for most Ruby applications that use OpenSSL.
|
10
|
-
|
11
|
-
Libraries that appear to work fine:
|
12
|
-
|
13
|
-
Rails, Net::HTTPS
|
14
|
-
|
15
|
-
Notable libraries that do *not* yet work include:
|
16
|
-
|
17
|
-
Net::SSH, Net::SFTP, etc.
|
18
|
-
|
19
9
|
Please report bugs and incompatibilities (preferably with testcases) to either the JRuby
|
20
10
|
mailing list [1] or the JRuby bug tracker [2].
|
21
11
|
|
22
12
|
[1]: http://xircles.codehaus.org/projects/jruby/lists
|
23
|
-
|
24
|
-
[2]: http://jira.codehaus.org/browse/JRUBY
|
13
|
+
[2]: http://jira.codehaus.org/browse/JRUBY
|
data/Rakefile
CHANGED
@@ -18,7 +18,7 @@ def java_classpath_arg # myriad of ways to discover JRuby classpath
|
|
18
18
|
FileList["#{ENV['JRUBY_HOME']}/lib/*.jar"].join(File::PATH_SEPARATOR)
|
19
19
|
end
|
20
20
|
bc_jars = BC_JARS.join(File::PATH_SEPARATOR)
|
21
|
-
jruby_cpath ? "-cp #{jruby_cpath}#{File::PATH_SEPARATOR}#{bc_jars}" : "-cp #{bc_jars}"
|
21
|
+
jruby_cpath ? "-cp \"#{jruby_cpath.gsub('\\', '/')}#{File::PATH_SEPARATOR}#{bc_jars}\"" : "-cp \"#{bc_jars}\""
|
22
22
|
end
|
23
23
|
|
24
24
|
desc "Compile the native Java code."
|
@@ -53,7 +53,8 @@ File.open("Manifest.txt", "w") {|f| MANIFEST.each {|n| f.puts n } }
|
|
53
53
|
require File.dirname(__FILE__) + "/lib/jopenssl/version"
|
54
54
|
begin
|
55
55
|
require 'hoe'
|
56
|
-
Hoe.
|
56
|
+
Hoe.plugin :gemcutter
|
57
|
+
hoe = Hoe.spec("jruby-openssl") do |p|
|
57
58
|
p.version = Jopenssl::Version::VERSION
|
58
59
|
p.rubyforge_name = "jruby-extras"
|
59
60
|
p.url = "http://jruby-extras.rubyforge.org/jruby-openssl"
|
@@ -61,9 +62,15 @@ begin
|
|
61
62
|
p.email = "ola.bini@gmail.com"
|
62
63
|
p.summary = "OpenSSL add-on for JRuby"
|
63
64
|
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
64
|
-
p.description = p.paragraphs_of('README.txt',
|
65
|
-
p.test_globs = ENV["TEST"] || ["test/
|
66
|
-
end
|
65
|
+
p.description = p.paragraphs_of('README.txt', 3...4).join("\n\n")
|
66
|
+
p.test_globs = ENV["TEST"] || ["test/test_all.rb"]
|
67
|
+
end
|
68
|
+
hoe.spec.dependencies.delete_if { |dep| dep.name == "hoe" }
|
69
|
+
|
70
|
+
task :gemspec do
|
71
|
+
File.open("#{hoe.name}.gemspec", "w") {|f| f << hoe.spec.to_ruby }
|
72
|
+
end
|
73
|
+
task :package => :gemspec
|
67
74
|
rescue LoadError
|
68
75
|
puts "You really need Hoe installed to be able to package this gem"
|
69
76
|
rescue => e
|
Binary file
|
Binary file
|
data/lib/jopenssl/version.rb
CHANGED
data/lib/jopenssl.jar
CHANGED
Binary file
|
data/lib/openssl/bn.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
=begin
|
2
|
-
= $RCSfile
|
2
|
+
= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for BN
|
3
3
|
|
4
4
|
= Info
|
5
5
|
'OpenSSL for Ruby 2' project
|
@@ -11,10 +11,12 @@
|
|
11
11
|
(See the file 'LICENCE'.)
|
12
12
|
|
13
13
|
= Version
|
14
|
-
$Id: bn.rb
|
14
|
+
$Id: bn.rb 11708 2007-02-12 23:01:19Z shyouhei $
|
15
15
|
=end
|
16
16
|
|
17
|
-
|
17
|
+
##
|
18
|
+
# Should we care what if somebody require this file directly?
|
19
|
+
#require 'openssl'
|
18
20
|
|
19
21
|
module OpenSSL
|
20
22
|
class BN
|
data/lib/openssl/buffering.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
=begin
|
2
|
-
= $RCSfile
|
2
|
+
= $RCSfile$ -- Buffering mix-in module.
|
3
3
|
|
4
4
|
= Info
|
5
5
|
'OpenSSL for Ruby 2' project
|
@@ -11,7 +11,7 @@
|
|
11
11
|
(See the file 'LICENCE'.)
|
12
12
|
|
13
13
|
= Version
|
14
|
-
$Id: buffering.rb
|
14
|
+
$Id: buffering.rb 13706 2007-10-15 08:29:08Z usa $
|
15
15
|
=end
|
16
16
|
|
17
17
|
module Buffering
|
data/lib/openssl/cipher.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
=begin
|
2
|
-
= $RCSfile
|
2
|
+
= $RCSfile$ -- Ruby-space predefined Cipher subclasses
|
3
3
|
|
4
4
|
= Info
|
5
5
|
'OpenSSL for Ruby 2' project
|
@@ -11,27 +11,15 @@
|
|
11
11
|
(See the file 'LICENCE'.)
|
12
12
|
|
13
13
|
= Version
|
14
|
-
$Id: cipher.rb
|
14
|
+
$Id: cipher.rb 12496 2007-06-08 15:02:04Z technorama $
|
15
15
|
=end
|
16
16
|
|
17
|
-
|
17
|
+
##
|
18
|
+
# Should we care what if somebody require this file directly?
|
19
|
+
#require 'openssl'
|
18
20
|
|
19
21
|
module OpenSSL
|
20
|
-
|
21
|
-
class Cipher
|
22
|
-
def random_key
|
23
|
-
str = OpenSSL::Random.random_bytes(self.key_len)
|
24
|
-
self.key = str
|
25
|
-
return str
|
26
|
-
end
|
27
|
-
|
28
|
-
def random_iv
|
29
|
-
str = OpenSSL::Random.random_bytes(self.iv_len)
|
30
|
-
self.iv = str
|
31
|
-
return str
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
22
|
+
class Cipher
|
35
23
|
%w(AES CAST5 BF DES IDEA RC2 RC4 RC5).each{|name|
|
36
24
|
klass = Class.new(Cipher){
|
37
25
|
define_method(:initialize){|*args|
|
@@ -52,5 +40,26 @@ module OpenSSL
|
|
52
40
|
}
|
53
41
|
const_set("AES#{keylen}", klass)
|
54
42
|
}
|
43
|
+
|
44
|
+
# Generate, set, and return a random key.
|
45
|
+
# You must call cipher.encrypt or cipher.decrypt before calling this method.
|
46
|
+
def random_key
|
47
|
+
str = OpenSSL::Random.random_bytes(self.key_len)
|
48
|
+
self.key = str
|
49
|
+
return str
|
50
|
+
end
|
51
|
+
|
52
|
+
# Generate, set, and return a random iv.
|
53
|
+
# You must call cipher.encrypt or cipher.decrypt before calling this method.
|
54
|
+
def random_iv
|
55
|
+
str = OpenSSL::Random.random_bytes(self.iv_len)
|
56
|
+
self.iv = str
|
57
|
+
return str
|
58
|
+
end
|
59
|
+
|
60
|
+
# This class is only provided for backwards compatibility. Use OpenSSL::Digest in the future.
|
61
|
+
class Cipher < Cipher
|
62
|
+
# add warning
|
63
|
+
end
|
55
64
|
end # Cipher
|
56
65
|
end # OpenSSL
|
data/lib/openssl/digest.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
=begin
|
2
|
-
= $RCSfile
|
2
|
+
= $RCSfile$ -- Ruby-space predefined Digest subclasses
|
3
3
|
|
4
4
|
= Info
|
5
5
|
'OpenSSL for Ruby 2' project
|
@@ -11,18 +11,25 @@
|
|
11
11
|
(See the file 'LICENCE'.)
|
12
12
|
|
13
13
|
= Version
|
14
|
-
$Id: digest.rb
|
14
|
+
$Id: digest.rb 15600 2008-02-25 08:48:57Z technorama $
|
15
15
|
=end
|
16
16
|
|
17
|
-
|
17
|
+
##
|
18
|
+
# Should we care what if somebody require this file directly?
|
19
|
+
#require 'openssl'
|
18
20
|
|
19
21
|
module OpenSSL
|
20
|
-
|
22
|
+
class Digest
|
21
23
|
|
22
24
|
alg = %w(DSS DSS1 MD2 MD4 MD5 MDC2 RIPEMD160 SHA SHA1)
|
23
25
|
if OPENSSL_VERSION_NUMBER > 0x00908000
|
24
26
|
alg += %w(SHA224 SHA256 SHA384 SHA512)
|
25
27
|
end
|
28
|
+
|
29
|
+
def self.digest(name, data)
|
30
|
+
super(data, name)
|
31
|
+
end
|
32
|
+
|
26
33
|
alg.each{|name|
|
27
34
|
klass = Class.new(Digest){
|
28
35
|
define_method(:initialize){|*data|
|
@@ -41,6 +48,14 @@ module OpenSSL
|
|
41
48
|
const_set(name, klass)
|
42
49
|
}
|
43
50
|
|
51
|
+
# This class is only provided for backwards compatibility. Use OpenSSL::Digest in the future.
|
52
|
+
class Digest < Digest
|
53
|
+
def initialize(*args)
|
54
|
+
# add warning
|
55
|
+
super(*args)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
44
59
|
end # Digest
|
45
60
|
end # OpenSSL
|
46
61
|
|
data/lib/openssl/dummy.rb
CHANGED
@@ -8,27 +8,27 @@ module OpenSSL
|
|
8
8
|
class Primitive; end
|
9
9
|
class Constructive; end
|
10
10
|
end
|
11
|
-
module PKey
|
12
|
-
class PKeyError < OpenSSLError; end
|
13
|
-
class PKey; def initialize(*args); end; end
|
14
|
-
class RSA < PKey; end
|
15
|
-
class DSA < PKey; end
|
16
|
-
class DH < PKey; end
|
17
|
-
end
|
18
11
|
module X509
|
19
12
|
class Name; end
|
20
13
|
class Certificate; end
|
21
14
|
class Extension; end
|
22
15
|
class CRL; end
|
23
16
|
class Revoked; end
|
24
|
-
class Store
|
17
|
+
class Store
|
18
|
+
def set_default_paths; end
|
19
|
+
end
|
25
20
|
class Request; end
|
26
21
|
class Attribute; end
|
27
22
|
end
|
28
23
|
module Netscape
|
29
24
|
class SPKI; end
|
30
25
|
end
|
31
|
-
|
32
|
-
class PKCS7
|
26
|
+
class PKCS7
|
27
|
+
# this definition causes TypeError "superclass mismatch for class PKCS7"
|
28
|
+
# MRI also crashes following definition;
|
29
|
+
# class Foo; class Foo < Foo; end; end
|
30
|
+
# class Foo; class Foo < Foo; end; end
|
31
|
+
#
|
32
|
+
# class PKCS7 < PKCS7; end
|
33
33
|
end
|
34
|
-
end
|
34
|
+
end
|
data/lib/openssl/dummyssl.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
=begin
|
2
|
+
= $RCSfile$ -- PKCS7
|
3
|
+
|
4
|
+
= Licence
|
5
|
+
This program is licenced under the same licence as Ruby.
|
6
|
+
(See the file 'LICENCE'.)
|
7
|
+
|
8
|
+
= Version
|
9
|
+
$Id: digest.rb 12148 2007-04-05 05:59:22Z technorama $
|
10
|
+
=end
|
11
|
+
|
12
|
+
module OpenSSL
|
13
|
+
class PKCS7
|
14
|
+
# This class is only provided for backwards compatibility. Use OpenSSL::PKCS7 in the future.
|
15
|
+
class PKCS7 < PKCS7
|
16
|
+
def initialize(*args)
|
17
|
+
super(*args)
|
18
|
+
|
19
|
+
warn("Warning: OpenSSL::PKCS7::PKCS7 is deprecated after Ruby 1.9; use OpenSSL::PKCS7 instead")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end # PKCS7
|
24
|
+
end # OpenSSL
|
25
|
+
|
data/lib/openssl/ssl.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
=begin
|
2
|
-
= $RCSfile
|
2
|
+
= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for SSL
|
3
3
|
|
4
4
|
= Info
|
5
5
|
'OpenSSL for Ruby 2' project
|
@@ -11,7 +11,7 @@
|
|
11
11
|
(See the file 'LICENCE'.)
|
12
12
|
|
13
13
|
= Version
|
14
|
-
$Id: ssl.rb
|
14
|
+
$Id: ssl.rb 16193 2008-04-25 06:51:21Z knu $
|
15
15
|
=end
|
16
16
|
|
17
17
|
require "openssl"
|
@@ -20,6 +20,33 @@ require "fcntl"
|
|
20
20
|
|
21
21
|
module OpenSSL
|
22
22
|
module SSL
|
23
|
+
class SSLContext
|
24
|
+
DEFAULT_PARAMS = {
|
25
|
+
:ssl_version => "SSLv23",
|
26
|
+
:verify_mode => OpenSSL::SSL::VERIFY_PEER,
|
27
|
+
:ciphers => "ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW",
|
28
|
+
:options => OpenSSL::SSL::OP_ALL,
|
29
|
+
}
|
30
|
+
|
31
|
+
DEFAULT_CERT_STORE = OpenSSL::X509::Store.new
|
32
|
+
DEFAULT_CERT_STORE.set_default_paths
|
33
|
+
if defined?(OpenSSL::X509::V_FLAG_CRL_CHECK_ALL)
|
34
|
+
DEFAULT_CERT_STORE.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_params(params={})
|
38
|
+
params = DEFAULT_PARAMS.merge(params)
|
39
|
+
self.ssl_version = params.delete(:ssl_version)
|
40
|
+
params.each{|name, value| self.__send__("#{name}=", value) }
|
41
|
+
if self.verify_mode != OpenSSL::SSL::VERIFY_NONE
|
42
|
+
unless self.ca_file or self.ca_path or self.cert_store
|
43
|
+
self.cert_store = DEFAULT_CERT_STORE
|
44
|
+
end
|
45
|
+
end
|
46
|
+
return params
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
23
50
|
module SocketForwarder
|
24
51
|
def addr
|
25
52
|
to_io.addr
|
@@ -53,42 +80,55 @@ module OpenSSL
|
|
53
80
|
module Nonblock
|
54
81
|
def initialize(*args)
|
55
82
|
flag = File::NONBLOCK
|
56
|
-
flag |= @io.fcntl(Fcntl::F_GETFL
|
83
|
+
flag |= @io.fcntl(Fcntl::F_GETFL) if defined?(Fcntl::F_GETFL)
|
57
84
|
@io.fcntl(Fcntl::F_SETFL, flag)
|
58
85
|
super
|
59
86
|
end
|
60
87
|
end
|
61
88
|
|
89
|
+
def verify_certificate_identity(cert, hostname)
|
90
|
+
should_verify_common_name = true
|
91
|
+
cert.extensions.each{|ext|
|
92
|
+
next if ext.oid != "subjectAltName"
|
93
|
+
ext.value.split(/,\s+/).each{|general_name|
|
94
|
+
if /\ADNS:(.*)/ =~ general_name
|
95
|
+
should_verify_common_name = false
|
96
|
+
reg = Regexp.escape($1).gsub(/\\\*/, "[^.]+")
|
97
|
+
return true if /\A#{reg}\z/i =~ hostname
|
98
|
+
elsif /\AIP Address:(.*)/ =~ general_name
|
99
|
+
should_verify_common_name = false
|
100
|
+
return true if $1 == hostname
|
101
|
+
end
|
102
|
+
}
|
103
|
+
}
|
104
|
+
if should_verify_common_name
|
105
|
+
cert.subject.to_a.each{|oid, value|
|
106
|
+
if oid == "CN"
|
107
|
+
reg = Regexp.escape(value).gsub(/\\\*/, "[^.]+")
|
108
|
+
return true if /\A#{reg}\z/i =~ hostname
|
109
|
+
end
|
110
|
+
}
|
111
|
+
end
|
112
|
+
return false
|
113
|
+
end
|
114
|
+
module_function :verify_certificate_identity
|
115
|
+
|
62
116
|
class SSLSocket
|
63
117
|
include Buffering
|
64
118
|
include SocketForwarder
|
65
119
|
include Nonblock
|
66
120
|
|
67
121
|
def post_connection_check(hostname)
|
68
|
-
|
69
|
-
|
70
|
-
cert.extensions.each{|ext|
|
71
|
-
next if ext.oid != "subjectAltName"
|
72
|
-
ext.value.split(/,\s+/).each{|general_name|
|
73
|
-
if /\ADNS:(.*)/ =~ general_name
|
74
|
-
check_common_name = false
|
75
|
-
reg = Regexp.escape($1).gsub(/\\\*/, "[^.]+")
|
76
|
-
return true if /\A#{reg}\z/i =~ hostname
|
77
|
-
elsif /\AIP Address:(.*)/ =~ general_name
|
78
|
-
check_common_name = false
|
79
|
-
return true if $1 == hostname
|
80
|
-
end
|
81
|
-
}
|
82
|
-
}
|
83
|
-
if check_common_name
|
84
|
-
cert.subject.to_a.each{|oid, value|
|
85
|
-
if oid == "CN"
|
86
|
-
reg = Regexp.escape(value).gsub(/\\\*/, "[^.]+")
|
87
|
-
return true if /\A#{reg}\z/i =~ hostname
|
88
|
-
end
|
89
|
-
}
|
122
|
+
unless OpenSSL::SSL.verify_certificate_identity(peer_cert, hostname)
|
123
|
+
raise SSLError, "hostname was not match with the server certificate"
|
90
124
|
end
|
91
|
-
|
125
|
+
return true
|
126
|
+
end
|
127
|
+
|
128
|
+
def session
|
129
|
+
SSL::Session.new(self)
|
130
|
+
rescue SSL::Session::SessionError
|
131
|
+
nil
|
92
132
|
end
|
93
133
|
end
|
94
134
|
|
@@ -114,6 +154,10 @@ module OpenSSL
|
|
114
154
|
@svr.listen(backlog)
|
115
155
|
end
|
116
156
|
|
157
|
+
def shutdown(how=Socket::SHUT_RDWR)
|
158
|
+
@svr.shutdown(how)
|
159
|
+
end
|
160
|
+
|
117
161
|
def accept
|
118
162
|
sock = @svr.accept
|
119
163
|
begin
|
data/lib/openssl/x509.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
=begin
|
2
|
-
= $RCSfile
|
2
|
+
= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for X509 and subclasses
|
3
3
|
|
4
4
|
= Info
|
5
5
|
'OpenSSL for Ruby 2' project
|
@@ -11,7 +11,7 @@
|
|
11
11
|
(See the file 'LICENCE'.)
|
12
12
|
|
13
13
|
= Version
|
14
|
-
$Id: x509.rb
|
14
|
+
$Id: x509.rb 11708 2007-02-12 23:01:19Z shyouhei $
|
15
15
|
=end
|
16
16
|
|
17
17
|
require "openssl"
|
data/lib/openssl.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
=begin
|
2
|
-
= $RCSfile
|
2
|
+
= $RCSfile$ -- Loader for all OpenSSL C-space and Ruby-space definitions
|
3
3
|
|
4
4
|
= Info
|
5
5
|
'OpenSSL for Ruby 2' project
|
@@ -11,14 +11,59 @@
|
|
11
11
|
(See the file 'LICENCE'.)
|
12
12
|
|
13
13
|
= Version
|
14
|
-
$Id: openssl.rb
|
14
|
+
$Id: openssl.rb 12496 2007-06-08 15:02:04Z technorama $
|
15
15
|
=end
|
16
16
|
|
17
|
+
# TODO: remove this chunk after 1.4 support is dropped
|
18
|
+
require 'digest'
|
19
|
+
unless defined?(::Digest::Class)
|
20
|
+
# restricted support for jruby <= 1.4 (1.8.6 Digest compat)
|
21
|
+
module Digest
|
22
|
+
class Class
|
23
|
+
def self.hexdigest(name, data)
|
24
|
+
digest(name, data).unpack('H*')[0]
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.digest(data, name)
|
28
|
+
digester = const_get(name).new
|
29
|
+
digester.update(data)
|
30
|
+
digester.finish
|
31
|
+
end
|
32
|
+
|
33
|
+
def hexdigest
|
34
|
+
digest.unpack('H*')[0]
|
35
|
+
end
|
36
|
+
|
37
|
+
def digest
|
38
|
+
dup.finish
|
39
|
+
end
|
40
|
+
|
41
|
+
def ==(oth)
|
42
|
+
digest == oth.digest
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_s
|
46
|
+
hexdigest
|
47
|
+
end
|
48
|
+
|
49
|
+
def size
|
50
|
+
digest_length
|
51
|
+
end
|
52
|
+
|
53
|
+
def length
|
54
|
+
digest_length
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
# end of compat chunk.
|
60
|
+
|
17
61
|
require 'jopenssl'
|
18
62
|
|
19
63
|
require 'openssl/bn'
|
20
64
|
require 'openssl/cipher'
|
21
65
|
require 'openssl/digest'
|
66
|
+
require 'openssl/pkcs7'
|
22
67
|
require 'openssl/ssl'
|
23
68
|
require 'openssl/x509'
|
24
69
|
|