aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl
diff options
context:
space:
mode:
authorgartens <41197811+gartens@users.noreply.github.com>2024-06-11 19:12:23 +0200
committerGitHub <noreply@github.com>2024-06-12 02:12:23 +0900
commitb0fc100091207d7eab20a349433ccbd8260c6ddd (patch)
treecda717a9b023cb4859184c5bc95a648789f6f97a /ext/openssl
parent72d1be92edfbf5ad8b99bae61230e72694cc61bb (diff)
downloadruby-openssl-b0fc100091207d7eab20a349433ccbd8260c6ddd.tar.gz
Pass through nil as digest when signing certificates (#761)
In order to sign certificates with Ed25519 keys, NULL must be passed as md to X509_sign. This NULL is then passed (via ASN1_item_sign_ex) as type to EVP_DigestSignInit. The documentation[1] of EVP_DigestSignInit states that type must be NULL for various key types, including Ed25519. [1]: https://www.openssl.org/docs/manmaster/man3/EVP_DigestSignInit.html
Diffstat (limited to 'ext/openssl')
-rw-r--r--ext/openssl/ossl_x509cert.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/openssl/ossl_x509cert.c b/ext/openssl/ossl_x509cert.c
index dbf83ff5..846dd070 100644
--- a/ext/openssl/ossl_x509cert.c
+++ b/ext/openssl/ossl_x509cert.c
@@ -539,7 +539,11 @@ ossl_x509_sign(VALUE self, VALUE key, VALUE digest)
const EVP_MD *md;
pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
- md = ossl_evp_get_digestbyname(digest);
+ if (NIL_P(digest)) {
+ md = NULL; /* needed for some key types, e.g. Ed25519 */
+ } else {
+ md = ossl_evp_get_digestbyname(digest);
+ }
GetX509(self, x509);
if (!X509_sign(x509, pkey, md)) {
ossl_raise(eX509CertError, NULL);