summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-21 21:09:51 +0000
committeremboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-21 21:09:51 +0000
commitee02506321aaef689c4e18fd07a16def30041782 (patch)
tree9fc65d1c82543e7bce81939392b31aa2776adb7f
parente48e12ec095836a665ab91969747ead59df9f464 (diff)
* test/openssl/test_x509cert.rb: Merge DSA-related tests from ruby_1_8
branch. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--test/openssl/test_x509cert.rb34
2 files changed, 39 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 00413366a60..2f65e5aad52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun May 22 06:07:17 2011 Martin Bosslet <Martin.Bosslet@googlemail.com>
+
+ * test/openssl/test_x509cert.rb: Merge DSA-related tests from ruby_1_8
+ branch.
+
Sun May 22 04:11:12 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* thread.c (Init_Thread): add a code comment why the meaningless
diff --git a/test/openssl/test_x509cert.rb b/test/openssl/test_x509cert.rb
index 6d39c9690dd..7af00293bf2 100644
--- a/test/openssl/test_x509cert.rb
+++ b/test/openssl/test_x509cert.rb
@@ -171,6 +171,40 @@ class OpenSSL::TestX509Certificate < Test::Unit::TestCase
}
end
+ def test_dsig_algorithm_mismatch
+ assert_raise(OpenSSL::X509::CertificateError) do
+ cert = issue_cert(@ca, @rsa2048, 1, Time.now, Time.now+3600, [],
+ nil, nil, OpenSSL::Digest::DSS1.new)
+ end
+ assert_raise(OpenSSL::X509::CertificateError) do
+ cert = issue_cert(@ca, @dsa512, 1, Time.now, Time.now+3600, [],
+ nil, nil, OpenSSL::Digest::MD5.new)
+ end
+ end
+
+ def test_dsa_with_sha2
+ begin
+ cert = issue_cert(@ca, @dsa256, 1, Time.now, Time.now+3600, [],
+ nil, nil, OpenSSL::Digest::SHA256.new)
+ assert_equal("dsa_with_SHA256", cert.signature_algorithm)
+ rescue OpenSSL::X509::CertificateError
+ # dsa_with_sha2 not supported. skip following test.
+ return
+ end
+ # TODO: need more tests for dsa + sha2
+
+ # SHA1 is allowed from OpenSSL 1.0.0 (0.9.8 requires DSS1)
+ cert = issue_cert(@ca, @dsa256, 1, Time.now, Time.now+3600, [],
+ nil, nil, OpenSSL::Digest::SHA1.new)
+ assert_equal("dsaWithSHA1", cert.signature_algorithm)
+ end
+
+ def test_check_private_key
+ cert = issue_cert(@ca, @rsa2048, 1, Time.now, Time.now+3600, [],
+ nil, nil, OpenSSL::Digest::SHA1.new)
+ assert_equal(true, cert.check_private_key(@rsa2048))
+ end
+
private
def certificate_error_returns_false