Skip to content
This repository was archived by the owner on Oct 29, 2021. It is now read-only.

Commit 5ab52ed

Browse files
committed
Fix build with OpenSSL 1.1.x
OpenSSL 1.1.x made many structs opaque and helpers are required to access members of struct. TX509_PUBKEY_get0_param returns 1 for succes and 0 on failure, this has not been handled yet by this patch.
1 parent e3db0e9 commit 5ab52ed

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/tls_openssl.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,15 @@ static struct _tlscert_t *_x509_to_tlscert(xmpp_ctx_t *ctx, X509 *cert)
168168
}
169169

170170
tlscert->keyalg = NULL;
171+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
171172
int alg_nid = OBJ_obj2nid(cert->cert_info->key->algor->algorithm);
173+
#else
174+
X509_PUBKEY *pubkey = X509_get_X509_PUBKEY(cert);
175+
ASN1_OBJECT *ppkalg;
176+
// FIXME: handle 0 on error.
177+
X509_PUBKEY_get0_param(&ppkalg, NULL, NULL, NULL, NULL);
178+
int alg_nid = OBJ_obj2nid(ppkalg);
179+
#endif
172180
if (alg_nid != NID_undef) {
173181
const char* keyalg = OBJ_nid2ln(alg_nid);
174182
if (keyalg) {
@@ -177,7 +185,13 @@ static struct _tlscert_t *_x509_to_tlscert(xmpp_ctx_t *ctx, X509 *cert)
177185
}
178186

179187
tlscert->sigalg = NULL;
188+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
180189
alg_nid = OBJ_obj2nid(cert->sig_alg->algorithm);
190+
#else
191+
const X509_ALGOR *palg;
192+
X509_get0_signature(NULL, &palg, cert);
193+
alg_nid = OBJ_obj2nid(palg->algorithm);
194+
#endif
181195
if (alg_nid != NID_undef) {
182196
const char* sigalg = OBJ_nid2ln(alg_nid);
183197
if (sigalg) {

0 commit comments

Comments
 (0)