diff options
author | emboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-27 00:31:43 +0000 |
---|---|---|
committer | emboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-27 00:31:43 +0000 |
commit | b9c485aa0d6f13303e7e9ab05c6d2b2496610a35 () | |
tree | 2ecbbec4e4bbf613ccb1846b25ca79f58f9f7038 | |
parent | 34fcd4406abd99db3d59b6b58aea52016c66e0fc (diff) |
* test/openssl/test_pkcs12.rb: Add test and intermediate certificates.
[ Ruby 1.9 - Feature #3793 ] [ruby-core:32088] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | test/openssl/test_pkcs12.rb | 108 |
2 files changed, 89 insertions, 24 deletions
@@ -1,3 +1,8 @@ Wed Jul 27 01:05:32 2011 Nobuyoshi Nakada <[email protected]> * eval_error.c (rb_print_undef_str): new function to raise @@ -7,18 +7,59 @@ module OpenSSL include OpenSSL::TestUtils def setup - @mycert = cert end def test_create pkcs12 = OpenSSL::PKCS12.create( "omg", "hello", - TEST_KEY_RSA2048, @mycert ) assert_equal @mycert, pkcs12.certificate - assert_equal TEST_KEY_RSA2048, pkcs12.key assert_nil pkcs12.ca_certs end @@ -26,11 +67,11 @@ module OpenSSL pkcs12 = OpenSSL::PKCS12.create( nil, "hello", - TEST_KEY_RSA2048, @mycert ) assert_equal @mycert, pkcs12.certificate - assert_equal TEST_KEY_RSA2048, pkcs12.key assert_nil pkcs12.ca_certs decoded = OpenSSL::PKCS12.new(pkcs12.to_der) @@ -38,24 +79,45 @@ module OpenSSL end def test_create_with_chain - chain = [cert, cert] pkcs12 = OpenSSL::PKCS12.create( "omg", "hello", - TEST_KEY_RSA2048, @mycert, chain ) assert_equal chain, pkcs12.ca_certs end def test_create_with_bad_nid assert_raises(ArgumentError) do OpenSSL::PKCS12.create( "omg", "hello", - TEST_KEY_RSA2048, @mycert, [], "foo" @@ -67,7 +129,7 @@ module OpenSSL OpenSSL::PKCS12.create( "omg", "hello", - TEST_KEY_RSA2048, @mycert, [], nil, @@ -79,7 +141,7 @@ module OpenSSL OpenSSL::PKCS12.create( "omg", "hello", - TEST_KEY_RSA2048, @mycert, [], nil, @@ -93,7 +155,7 @@ module OpenSSL OpenSSL::PKCS12.create( "omg", "hello", - TEST_KEY_RSA2048, @mycert, [], nil, @@ -106,7 +168,7 @@ module OpenSSL OpenSSL::PKCS12.create( "omg", "hello", - TEST_KEY_RSA2048, @mycert, [], nil, @@ -128,21 +190,19 @@ module OpenSSL ].each do |attribute| assert_equal expected.send(attribute), actual.send(attribute) end end - def cert - ca = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=CA") - - now = Time.now - ca_exts = [ - ["basicConstraints","CA:TRUE",true], - ["keyUsage","keyCertSign, cRLSign",true], - ["subjectKeyIdentifier","hash",false], - ["authorityKeyIdentifier","keyid:always",false], - ] - issue_cert(ca, TEST_KEY_RSA2048, 1, now, now+3600, ca_exts, - nil, nil, OpenSSL::Digest::SHA1.new) end end end |