mirror of https://github.com/openssl/openssl
Use more X509_REQ_get0_pubkey & X509_get0_pubkey
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1284)
This commit is contained in:
parent
415e7c488e
commit
1c72f70df4
10
apps/req.c
10
apps/req.c
|
@ -727,15 +727,14 @@ int req_main(int argc, char **argv)
|
|||
goto end;
|
||||
|
||||
if (pubkey) {
|
||||
EVP_PKEY *tpubkey;
|
||||
tpubkey = X509_REQ_get_pubkey(req);
|
||||
EVP_PKEY *tpubkey = X509_REQ_get0_pubkey(req);
|
||||
|
||||
if (tpubkey == NULL) {
|
||||
BIO_printf(bio_err, "Error getting public key\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
PEM_write_bio_PUBKEY(out, tpubkey);
|
||||
EVP_PKEY_free(tpubkey);
|
||||
}
|
||||
|
||||
if (text) {
|
||||
|
@ -758,9 +757,9 @@ int req_main(int argc, char **argv)
|
|||
EVP_PKEY *tpubkey;
|
||||
|
||||
if (x509)
|
||||
tpubkey = X509_get_pubkey(x509ss);
|
||||
tpubkey = X509_get0_pubkey(x509ss);
|
||||
else
|
||||
tpubkey = X509_REQ_get_pubkey(req);
|
||||
tpubkey = X509_REQ_get0_pubkey(req);
|
||||
if (tpubkey == NULL) {
|
||||
fprintf(stdout, "Modulus=unavailable\n");
|
||||
goto end;
|
||||
|
@ -774,7 +773,6 @@ int req_main(int argc, char **argv)
|
|||
} else
|
||||
#endif
|
||||
fprintf(stdout, "Wrong Algorithm type");
|
||||
EVP_PKEY_free(tpubkey);
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -86,13 +86,12 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags,
|
|||
if (BIO_puts(bp, "\n") <= 0)
|
||||
goto err;
|
||||
|
||||
pkey = X509_REQ_get_pubkey(x);
|
||||
pkey = X509_REQ_get0_pubkey(x);
|
||||
if (pkey == NULL) {
|
||||
BIO_printf(bp, "%12sUnable to load Public Key\n", "");
|
||||
ERR_print_errors(bp);
|
||||
} else {
|
||||
EVP_PKEY_print_public(bp, pkey, 16, NULL);
|
||||
EVP_PKEY_free(pkey);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -852,11 +852,11 @@ static void print_details(SSL *c_ssl, const char *prefix)
|
|||
SSL_CIPHER_get_version(ciph), SSL_CIPHER_get_name(ciph));
|
||||
cert = SSL_get_peer_certificate(c_ssl);
|
||||
if (cert != NULL) {
|
||||
pkey = X509_get_pubkey(cert);
|
||||
if (pkey != NULL) {
|
||||
EVP_PKEY* pubkey = X509_get0_pubkey(cert);
|
||||
|
||||
if (pubkey != NULL) {
|
||||
BIO_puts(bio_stdout, ", ");
|
||||
print_key_details(bio_stdout, pkey);
|
||||
EVP_PKEY_free(pkey);
|
||||
print_key_details(bio_stdout, pubkey);
|
||||
}
|
||||
X509_free(cert);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue