Commit 1c72f70d authored by FdaSilvaYY's avatar FdaSilvaYY Committed by Rich Salz
Browse files

Use more X509_REQ_get0_pubkey & X509_get0_pubkey

parent 415e7c48
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -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");
    }

+1 −2
Original line number Diff line number Diff line
@@ -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);
        }
    }

+4 −4
Original line number Diff line number Diff line
@@ -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);
    }