jruby-openssl 0.8.0.pre3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/Manifest.txt +5 -124
  2. data/Rakefile +3 -3
  3. data/lib/shared/jopenssl.jar +0 -0
  4. data/lib/shared/jopenssl/version.rb +1 -1
  5. metadata +10 -116
  6. data/test/1.8/ssl_server.rb +0 -99
  7. data/test/1.8/test_asn1.rb +0 -212
  8. data/test/1.8/test_cipher.rb +0 -193
  9. data/test/1.8/test_config.rb +0 -290
  10. data/test/1.8/test_digest.rb +0 -88
  11. data/test/1.8/test_ec.rb +0 -128
  12. data/test/1.8/test_hmac.rb +0 -46
  13. data/test/1.8/test_ns_spki.rb +0 -59
  14. data/test/1.8/test_pair.rb +0 -149
  15. data/test/1.8/test_pkcs7.rb +0 -489
  16. data/test/1.8/test_pkey_rsa.rb +0 -49
  17. data/test/1.8/test_ssl.rb +0 -1032
  18. data/test/1.8/test_x509cert.rb +0 -277
  19. data/test/1.8/test_x509crl.rb +0 -253
  20. data/test/1.8/test_x509ext.rb +0 -99
  21. data/test/1.8/test_x509name.rb +0 -290
  22. data/test/1.8/test_x509req.rb +0 -195
  23. data/test/1.8/test_x509store.rb +0 -246
  24. data/test/1.8/utils.rb +0 -144
  25. data/test/1.9/ssl_server.rb +0 -81
  26. data/test/1.9/test_asn1.rb +0 -589
  27. data/test/1.9/test_bn.rb +0 -23
  28. data/test/1.9/test_buffering.rb +0 -88
  29. data/test/1.9/test_cipher.rb +0 -107
  30. data/test/1.9/test_config.rb +0 -288
  31. data/test/1.9/test_digest.rb +0 -118
  32. data/test/1.9/test_engine.rb +0 -15
  33. data/test/1.9/test_hmac.rb +0 -32
  34. data/test/1.9/test_ns_spki.rb +0 -50
  35. data/test/1.9/test_ocsp.rb +0 -47
  36. data/test/1.9/test_pair.rb +0 -257
  37. data/test/1.9/test_pkcs12.rb +0 -209
  38. data/test/1.9/test_pkcs7.rb +0 -156
  39. data/test/1.9/test_pkey_dh.rb +0 -72
  40. data/test/1.9/test_pkey_dsa.rb +0 -224
  41. data/test/1.9/test_pkey_ec.rb +0 -182
  42. data/test/1.9/test_pkey_rsa.rb +0 -244
  43. data/test/1.9/test_ssl.rb +0 -499
  44. data/test/1.9/test_ssl_session.rb +0 -327
  45. data/test/1.9/test_x509cert.rb +0 -217
  46. data/test/1.9/test_x509crl.rb +0 -221
  47. data/test/1.9/test_x509ext.rb +0 -69
  48. data/test/1.9/test_x509name.rb +0 -366
  49. data/test/1.9/test_x509req.rb +0 -150
  50. data/test/1.9/test_x509store.rb +0 -229
  51. data/test/1.9/utils.rb +0 -304
  52. data/test/cert_with_ec_pk.cer +0 -27
  53. data/test/fixture/ca-bundle.crt +0 -2794
  54. data/test/fixture/ca_path/72fa7371.0 +0 -19
  55. data/test/fixture/ca_path/verisign.pem +0 -19
  56. data/test/fixture/cacert.pem +0 -23
  57. data/test/fixture/cert_localhost.pem +0 -19
  58. data/test/fixture/common.pem +0 -48
  59. data/test/fixture/ids_in_subject_rdn_set.pem +0 -31
  60. data/test/fixture/imaps/cacert.pem +0 -60
  61. data/test/fixture/imaps/server.crt +0 -61
  62. data/test/fixture/imaps/server.key +0 -15
  63. data/test/fixture/key_then_cert.pem +0 -34
  64. data/test/fixture/keypair.pem +0 -27
  65. data/test/fixture/localhost_keypair.pem +0 -18
  66. data/test/fixture/max.pem +0 -29
  67. data/test/fixture/purpose/b70a5bc1.0 +0 -24
  68. data/test/fixture/purpose/ca/PASSWD_OF_CA_KEY_IS_1234 +0 -0
  69. data/test/fixture/purpose/ca/ca_config.rb +0 -37
  70. data/test/fixture/purpose/ca/cacert.pem +0 -24
  71. data/test/fixture/purpose/ca/newcerts/2_cert.pem +0 -19
  72. data/test/fixture/purpose/ca/newcerts/3_cert.pem +0 -19
  73. data/test/fixture/purpose/ca/newcerts/4_cert.pem +0 -19
  74. data/test/fixture/purpose/ca/private/cakeypair.pem +0 -30
  75. data/test/fixture/purpose/ca/serial +0 -1
  76. data/test/fixture/purpose/cacert.pem +0 -24
  77. data/test/fixture/purpose/scripts/gen_cert.rb +0 -127
  78. data/test/fixture/purpose/scripts/gen_csr.rb +0 -50
  79. data/test/fixture/purpose/scripts/init_ca.rb +0 -66
  80. data/test/fixture/purpose/sslclient.pem +0 -19
  81. data/test/fixture/purpose/sslclient/csr.pem +0 -10
  82. data/test/fixture/purpose/sslclient/keypair.pem +0 -15
  83. data/test/fixture/purpose/sslclient/sslclient.pem +0 -19
  84. data/test/fixture/purpose/sslserver.pem +0 -19
  85. data/test/fixture/purpose/sslserver/csr.pem +0 -10
  86. data/test/fixture/purpose/sslserver/keypair.pem +0 -15
  87. data/test/fixture/purpose/sslserver/sslserver.pem +0 -19
  88. data/test/fixture/purpose/sslserver_no_dsig_in_keyUsage.pem +0 -19
  89. data/test/fixture/selfcert.pem +0 -23
  90. data/test/fixture/verisign.pem +0 -19
  91. data/test/fixture/verisign_c3.pem +0 -14
  92. data/test/ref/a.out +0 -0
  93. data/test/ref/compile.rb +0 -8
  94. data/test/ref/pkcs1 +0 -0
  95. data/test/ref/pkcs1.c +0 -21
  96. data/test/ruby/envutil.rb +0 -208
  97. data/test/ruby/ut_eof.rb +0 -128
  98. data/test/test_all.rb +0 -1
  99. data/test/test_certificate.rb +0 -132
  100. data/test/test_cipher.rb +0 -197
  101. data/test/test_imaps.rb +0 -107
  102. data/test/test_integration.rb +0 -144
  103. data/test/test_openssl.rb +0 -4
  104. data/test/test_parse_certificate.rb +0 -27
  105. data/test/test_pkcs7.rb +0 -56
  106. data/test/test_pkey_dsa.rb +0 -180
  107. data/test/test_pkey_rsa.rb +0 -329
  108. data/test/test_ssl.rb +0 -97
  109. data/test/test_x509store.rb +0 -168
@@ -1,97 +0,0 @@
1
- require 'openssl'
2
- require 'test/unit'
3
- require 'webrick/https'
4
- require 'net/https'
5
- require 'logger'
6
- require File.join(File.dirname(__FILE__), (RUBY_VERSION >= '1.9.0' ? '1.9' : '1.8'), "utils.rb")
7
-
8
-
9
- class TestSSL < Test::Unit::TestCase
10
- PORT = 17171
11
- DIR = File.dirname(File.expand_path(__FILE__))
12
-
13
- def setup
14
- @server = @server_thread = nil
15
- @verbose, $VERBOSE = $VERBOSE, nil
16
- setup_server
17
- end
18
-
19
- def teardown
20
- $VERBOSE = @verbose
21
- teardown_server
22
- end
23
-
24
- def test_jruby_4826
25
- assert_nothing_raised do
26
- 100.times do
27
- http = Net::HTTP.new('localhost', PORT)
28
- http.use_ssl = true
29
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
30
- req = Net::HTTP::Post.new('/post')
31
- http.request(req).body
32
- end
33
- end
34
- end
35
-
36
- private
37
-
38
- def make_certificate(key, cn)
39
- subject = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=#{cn}")
40
- exts = [
41
- ["keyUsage", "keyEncipherment,digitalSignature", true],
42
- ]
43
- OpenSSL::TestUtils.issue_cert(
44
- subject, key, 1, Time.now, Time.now + 3600, exts,
45
- nil, nil, OpenSSL::Digest::SHA1.new
46
- )
47
- end
48
-
49
- def setup_server
50
- key = OpenSSL::TestUtils::TEST_KEY_RSA1024
51
- cert = make_certificate(key, "localhost")
52
- logger = Logger.new(STDERR)
53
- logger.level = Logger::Severity::FATAL # avoid logging SSLError (ERROR level)
54
- @server = WEBrick::HTTPServer.new(
55
- :Logger => logger,
56
- :Port => PORT,
57
- :AccessLog => [],
58
- :SSLEnable => true,
59
- :ServerName => "localhost",
60
- :SSLCertificate => cert,
61
- :SSLPrivateKey => key
62
- )
63
- @server.mount(
64
- "/post",
65
- WEBrick::HTTPServlet::ProcHandler.new(method("do_post").to_proc)
66
- )
67
- @server_thread = start_server_thread(@server)
68
- end
69
-
70
- def do_post(req, res)
71
- res.chunked = true
72
- res['content-type'] = 'text/plain'
73
- piper, pipew = IO.pipe
74
- res.body = piper
75
- 10.times { pipew << "A" * 10 }
76
- pipew.close
77
- end
78
-
79
- def start_server_thread(server)
80
- t = Thread.new {
81
- Thread.current.abort_on_exception = true
82
- server.start
83
- }
84
- while server.status != :Running
85
- Thread.pass
86
- unless t.alive?
87
- t.join
88
- raise
89
- end
90
- end
91
- t
92
- end
93
-
94
- def teardown_server
95
- @server.shutdown if @server
96
- end
97
- end
@@ -1,168 +0,0 @@
1
- begin
2
- require "openssl"
3
- rescue LoadError
4
- end
5
-
6
- require "test/unit"
7
- require "tempfile"
8
-
9
- class TestX509Store < Test::Unit::TestCase
10
- def setup
11
- @store = OpenSSL::X509::Store.new
12
- end
13
-
14
- def path(file)
15
- File.expand_path(file, File.dirname(__FILE__))
16
- end
17
-
18
- def teardown
19
- end
20
-
21
- def test_ns_cert_type
22
- f = Tempfile.new("globalsign-root.pem")
23
- f << GLOBALSIGN_ROOT_CA
24
- f.close
25
- @store.add_file(f.path)
26
- f.unlink
27
-
28
- # CAUTION !
29
- #
30
- # sgc is an issuing CA certificate so we should not verify it for the
31
- # purpose 'PURPOSE_SSL_SERVER'. It's not a SSL server certificate.
32
- # We're just checking the code for 'PURPOSE_SSL_SERVER'.
33
- # jruby-openssl/0.5.2 raises the following exception around ASN.1
34
- # nsCertType handling.
35
- # Purpose.java:344:in `call': java.lang.ClassCastException: org.bouncycastle.asn1.DEROctetString cannot be cast to org.bouncycastle.asn1.DERBitString
36
- sgc = OpenSSL::X509::Certificate.new(GLOBALSIGN_ORGANIZATION_VALIDATION_CA)
37
-
38
- @store.purpose = OpenSSL::X509::PURPOSE_SSL_SERVER
39
- assert_nothing_raised do
40
- @store.verify(sgc) # => should be false
41
- end
42
- end
43
-
44
- def test_purpose_ssl_client
45
- @store.add_file(path("fixture/purpose/cacert.pem"))
46
- cert = OpenSSL::X509::Certificate.new(File.read(path("fixture/purpose/sslclient.pem")))
47
- @store.purpose = OpenSSL::X509::PURPOSE_SSL_CLIENT
48
- assert_equal(true, @store.verify(cert))
49
- @store.purpose = OpenSSL::X509::PURPOSE_SSL_SERVER
50
- assert_equal(false, @store.verify(cert))
51
- @store.purpose = OpenSSL::X509::PURPOSE_SSL_CLIENT
52
- assert_equal(true, @store.verify(cert))
53
- end
54
-
55
- def test_purpose_ssl_server
56
- @store.add_file(path("fixture/purpose/cacert.pem"))
57
- cert = OpenSSL::X509::Certificate.new(File.read(path("fixture/purpose/sslserver.pem")))
58
- @store.purpose = OpenSSL::X509::PURPOSE_SSL_SERVER
59
- assert_equal(true, @store.verify(cert))
60
- @store.purpose = OpenSSL::X509::PURPOSE_SSL_CLIENT
61
- assert_equal(false, @store.verify(cert))
62
- @store.purpose = OpenSSL::X509::PURPOSE_SSL_SERVER
63
- assert_equal(true, @store.verify(cert))
64
- end
65
-
66
- # keyUsage: no digitalSignature bit, keyEncipherment bit only.
67
- def test_purpose_ssl_server_no_dsig_in_keyUsage
68
- @store.add_file(path("fixture/purpose/cacert.pem"))
69
- cert = OpenSSL::X509::Certificate.new(File.read(path("fixture/purpose/sslserver_no_dsig_in_keyUsage.pem")))
70
- @store.purpose = OpenSSL::X509::PURPOSE_SSL_SERVER
71
- assert_equal(true, @store.verify(cert))
72
- end
73
-
74
- def test_add_file_multiple
75
- f = Tempfile.new("globalsign-root.pem")
76
- f << GLOBALSIGN_ROOT_CA
77
- f << "junk junk\n"
78
- f << "junk junk\n"
79
- f << "junk junk\n"
80
- f << File.read(path("fixture/purpose/cacert.pem"))
81
- f.close
82
- @store.add_file(f.path)
83
- f.unlink
84
-
85
- cert = OpenSSL::X509::Certificate.new(File.read(path("fixture/purpose/sslserver.pem")))
86
- @store.purpose = OpenSSL::X509::PURPOSE_SSL_SERVER
87
- assert_equal(true, @store.verify(cert))
88
- @store.purpose = OpenSSL::X509::PURPOSE_SSL_CLIENT
89
- assert_equal(false, @store.verify(cert))
90
- @store.purpose = OpenSSL::X509::PURPOSE_SSL_SERVER
91
- assert_equal(true, @store.verify(cert))
92
- end
93
-
94
- # jruby-openssl/0.6 raises "can't store certificate" because of duplicated
95
- # subject. ruby-openssl just ignores the second certificate.
96
- def test_add_file_JRUBY_4409
97
- assert_nothing_raised do
98
- @store.add_file(path("fixture/ca-bundle.crt"))
99
- end
100
- end
101
-
102
- def test_set_default_paths
103
- @store.purpose = OpenSSL::X509::PURPOSE_SSL_SERVER
104
- cert = OpenSSL::X509::Certificate.new(File.read(path("fixture/purpose/sslserver.pem")))
105
- assert_equal(false, @store.verify(cert))
106
- begin
107
- backup = ENV['SSL_CERT_DIR']
108
- ENV['SSL_CERT_DIR'] = path('fixture/purpose/')
109
- @store.set_default_paths
110
- assert_equal(true, @store.verify(cert))
111
- ensure
112
- ENV['SSL_CERT_DIR'] = backup if backup
113
- end
114
- end
115
-
116
- GLOBALSIGN_ROOT_CA = <<__EOS__
117
- -----BEGIN CERTIFICATE-----
118
- MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG
119
- A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv
120
- b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw
121
- MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i
122
- YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT
123
- aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ
124
- jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp
125
- xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp
126
- 1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG
127
- snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ
128
- U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8
129
- 9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E
130
- BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B
131
- AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz
132
- yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE
133
- 38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP
134
- AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad
135
- DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME
136
- HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
137
- -----END CERTIFICATE-----
138
- __EOS__
139
-
140
- GLOBALSIGN_ORGANIZATION_VALIDATION_CA = <<__EOS__
141
- -----BEGIN CERTIFICATE-----
142
- MIIEZzCCA0+gAwIBAgILBAAAAAABHkSl9SowDQYJKoZIhvcNAQEFBQAwVzELMAkG
143
- A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv
144
- b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw0wNzA0MTExMjAw
145
- MDBaFw0xNzA0MTExMjAwMDBaMGoxIzAhBgNVBAsTGk9yZ2FuaXphdGlvbiBWYWxp
146
- ZGF0aW9uIENBMRMwEQYDVQQKEwpHbG9iYWxTaWduMS4wLAYDVQQDEyVHbG9iYWxT
147
- aWduIE9yZ2FuaXphdGlvbiBWYWxpZGF0aW9uIENBMIIBIjANBgkqhkiG9w0BAQEF
148
- AAOCAQ8AMIIBCgKCAQEAoS/EvM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e413mrDO9BNS05QslY2DERd2hplKuaYVqljMy4E567o9I63stp9wMjirqYoL+PJ
165
- c738B0E0t6pu7qfb0ZM87ZDsMpKI2cgjbHQh
166
- -----END CERTIFICATE-----
167
- __EOS__
168
- end