aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_x509cert.c
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2017-11-25 22:04:04 +0900
committerKazuki Yamaguchi <k@rhe.jp>2017-11-25 22:04:04 +0900
commited15e4c51f517227e092b1e3b993b04a27c92e05 (patch)
tree76bbb1bc97bc7e4fd1423bb6aaa43631651b3a90 /ext/openssl/ossl_x509cert.c
parent4e53940676a23a021d2f0543c2349396ea3cf430 (diff)
parentf3b596e858ea1604d0ea5653bffe80672c22f079 (diff)
downloadruby-openssl-ed15e4c51f517227e092b1e3b993b04a27c92e05.tar.gz
Merge branch 'maint'
* maint: History.md: fix a typo x509cert, x509crl, x509req, ns_spki: check sanity of public key pkey: make pkey_check_public_key() non-static test/test_cipher: fix test_non_aead_cipher_set_auth_data failure cipher: disallow setting AAD for non-AEAD ciphers test/test_ssl_session: skip tests for session_remove_cb appveyor.yml: remove 'openssl version' line
Diffstat (limited to 'ext/openssl/ossl_x509cert.c')
-rw-r--r--ext/openssl/ossl_x509cert.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/ext/openssl/ossl_x509cert.c b/ext/openssl/ossl_x509cert.c
index 8d16b9b7..40542c4a 100644
--- a/ext/openssl/ossl_x509cert.c
+++ b/ext/openssl/ossl_x509cert.c
@@ -508,18 +508,19 @@ ossl_x509_get_public_key(VALUE self)
/*
* call-seq:
- * cert.public_key = key => key
+ * cert.public_key = key
*/
static VALUE
ossl_x509_set_public_key(VALUE self, VALUE key)
{
X509 *x509;
+ EVP_PKEY *pkey;
GetX509(self, x509);
- if (!X509_set_pubkey(x509, GetPKeyPtr(key))) { /* DUPs pkey */
- ossl_raise(eX509CertError, NULL);
- }
-
+ pkey = GetPKeyPtr(key);
+ ossl_pkey_check_public_key(pkey);
+ if (!X509_set_pubkey(x509, pkey))
+ ossl_raise(eX509CertError, "X509_set_pubkey");
return key;
}
@@ -557,9 +558,9 @@ ossl_x509_verify(VALUE self, VALUE key)
X509 *x509;
EVP_PKEY *pkey;
- pkey = GetPKeyPtr(key); /* NO NEED TO DUP */
GetX509(self, x509);
-
+ pkey = GetPKeyPtr(key);
+ ossl_pkey_check_public_key(pkey);
switch (X509_verify(x509, pkey)) {
case 1:
return Qtrue;