Skip to content

Commit

Permalink
Fix BZ 65181 Improve support for using OpenSSL Engines
Browse files Browse the repository at this point in the history
Improve support for using OpenSSL Engines that use proprietary key
formats. Patch provided by Edin Hodizc.

https://bz.apache.org/bugzilla/show_bug.cgi?id=65181
  • Loading branch information
markt-asf committed Mar 25, 2021
1 parent 9f984b5 commit 69e884a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions native/include/ssl_private.h
Expand Up @@ -51,6 +51,7 @@
*/
#ifndef OPENSSL_NO_ENGINE
#include <openssl/engine.h>
extern ENGINE *tcn_ssl_engine;
#endif

#ifndef RAND_MAX
Expand Down
8 changes: 7 additions & 1 deletion native/src/sslcontext.c
Expand Up @@ -1034,7 +1034,13 @@ TCN_IMPLEMENT_CALL(jboolean, SSLContext, setCertificate)(TCN_STDARGS, jlong ctx,
}
}
else {
if ((c->keys[idx] = load_pem_key(c, key_file)) == NULL) {
if ((c->keys[idx] = load_pem_key(c, key_file)) == NULL
#ifndef OPENSSL_NO_ENGINE
&& tcn_ssl_engine != NULL &&
(c->keys[idx] = ENGINE_load_private_key(tcn_ssl_engine, key_file,
NULL, NULL)) == NULL
#endif
) {
ERR_error_string(SSL_ERR_get(), err);
tcn_Throw(e, "Unable to load certificate key %s (%s)",
key_file, err);
Expand Down
6 changes: 6 additions & 0 deletions xdocs/miscellaneous/changelog.xml
Expand Up @@ -35,6 +35,12 @@
</p>
</section>
<section name="Changes in 1.2.27">
<changelog>
<add>
<bug>65181</bug>: Improve support for using OpenSSL Engines that use
proprietary key formats. Patch provided by Edin Hodizc. (markt)
</add>
</changelog>
</section>
<section name="Changes in 1.2.26">
<changelog>
Expand Down

0 comments on commit 69e884a

Please sign in to comment.