|
79 | 79 | #include <openssl/bio.h>
|
80 | 80 | #include <openssl/buffer.h>
|
81 | 81 | #include <openssl/pkcs12.h>
|
| 82 | +#include <openssl/tls1.h> |
| 83 | +#include <openssl/evp.h> |
82 | 84 |
|
83 | 85 | #if (OPENSSL_VERSION_NUMBER >= 0x0090808fL) && !defined(OPENSSL_NO_OCSP)
|
84 | 86 | #include <openssl/ocsp.h>
|
@@ -3986,13 +3988,28 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf,
|
3986 | 3988 | }
|
3987 | 3989 | }
|
3988 | 3990 | else {
|
| 3991 | + int psigtype_nid = NID_undef; |
| 3992 | + const char *negotiated_group_name = NULL; |
| 3993 | + |
3989 | 3994 | /* we connected fine, we're not waiting for anything else. */
|
3990 | 3995 | connssl->connecting_state = ssl_connect_3;
|
3991 | 3996 |
|
| 3997 | +#if (OPENSSL_VERSION_NUMBER >= 0x30000000L) |
| 3998 | + SSL_get_peer_signature_type_nid(backend->handle, &psigtype_nid); |
| 3999 | +#if (OPENSSL_VERSION_NUMBER >= 0x30200000L) |
| 4000 | + negotiated_group_name = SSL_get0_group_name(backend->handle); |
| 4001 | +#else |
| 4002 | + negotiated_group_name = |
| 4003 | + OBJ_nid2sn(SSL_get_negotiated_group(backend->handle) & 0x0000FFFF); |
| 4004 | +#endif |
| 4005 | +#endif |
| 4006 | + |
3992 | 4007 | /* Informational message */
|
3993 |
| - infof(data, "SSL connection using %s / %s", |
| 4008 | + infof(data, "SSL connection using %s / %s / %s / %s", |
3994 | 4009 | SSL_get_version(backend->handle),
|
3995 |
| - SSL_get_cipher(backend->handle)); |
| 4010 | + SSL_get_cipher(backend->handle), |
| 4011 | + negotiated_group_name == NULL ? NULL : negotiated_group_name, |
| 4012 | + OBJ_nid2sn(psigtype_nid)); |
3996 | 4013 |
|
3997 | 4014 | #ifdef HAS_ALPN
|
3998 | 4015 | /* Sets data and len to negotiated protocol, len is 0 if no protocol was
|
@@ -4068,6 +4085,60 @@ static CURLcode ossl_pkp_pin_peer_pubkey(struct Curl_easy *data, X509* cert,
|
4068 | 4085 |
|
4069 | 4086 | return result;
|
4070 | 4087 | }
|
| 4088 | +#if (OPENSSL_VERSION_NUMBER >= 0x30000000L) && \ |
| 4089 | + !defined(CURL_DISABLE_VERBOSE_STRINGS) |
| 4090 | +static void infof_certstack(struct Curl_easy *data, const SSL *ssl) |
| 4091 | +{ |
| 4092 | + STACK_OF(X509) *certstack; |
| 4093 | + long verify_result; |
| 4094 | + int num_cert_levels; |
| 4095 | + int cert_level; |
| 4096 | + |
| 4097 | + verify_result = SSL_get_verify_result(ssl); |
| 4098 | + if(verify_result != X509_V_OK) |
| 4099 | + certstack = SSL_get_peer_cert_chain(ssl); |
| 4100 | + else |
| 4101 | + certstack = SSL_get0_verified_chain(ssl); |
| 4102 | + num_cert_levels = sk_X509_num(certstack); |
| 4103 | + OpenSSL_add_all_algorithms(); |
| 4104 | + OpenSSL_add_all_digests(); |
| 4105 | + |
| 4106 | + for(cert_level = 0; cert_level < num_cert_levels; cert_level++) { |
| 4107 | + char cert_algorithm[80] = ""; |
| 4108 | + char group_name[80] = ""; |
| 4109 | + char group_name_final[80] = ""; |
| 4110 | + const X509_ALGOR *palg_cert = NULL; |
| 4111 | + const ASN1_OBJECT *paobj_cert = NULL; |
| 4112 | + X509 *current_cert; |
| 4113 | + EVP_PKEY *current_pkey; |
| 4114 | + int key_bits; |
| 4115 | + int key_sec_bits; |
| 4116 | + int get_group_name; |
| 4117 | + |
| 4118 | + current_cert = sk_X509_value(certstack, cert_level); |
| 4119 | + |
| 4120 | + X509_get0_signature(NULL, &palg_cert, current_cert); |
| 4121 | + X509_ALGOR_get0(&paobj_cert, NULL, NULL, palg_cert); |
| 4122 | + OBJ_obj2txt(cert_algorithm, sizeof(cert_algorithm), paobj_cert, 0); |
| 4123 | + |
| 4124 | + current_pkey = X509_get0_pubkey(current_cert); |
| 4125 | + key_bits = EVP_PKEY_bits(current_pkey); |
| 4126 | + key_sec_bits = EVP_PKEY_get_security_bits(current_pkey); |
| 4127 | + get_group_name = EVP_PKEY_get_group_name(current_pkey, group_name, |
| 4128 | + sizeof(group_name), NULL); |
| 4129 | + msnprintf(group_name_final, sizeof(group_name_final), "/%s", group_name); |
| 4130 | + |
| 4131 | + infof(data, |
| 4132 | + " Certificate level %d: " |
| 4133 | + "Public key type %s%s (%d/%d Bits/secBits), signed using %s", |
| 4134 | + cert_level, EVP_PKEY_get0_type_name(current_pkey), |
| 4135 | + get_group_name == 0 ? "" : group_name_final, |
| 4136 | + key_bits, key_sec_bits, cert_algorithm); |
| 4137 | + } |
| 4138 | +} |
| 4139 | +#else |
| 4140 | +#define infof_certstack(data, ssl) |
| 4141 | +#endif |
4071 | 4142 |
|
4072 | 4143 | /*
|
4073 | 4144 | * Get the server cert, verify it and show it, etc., only call failf() if the
|
@@ -4258,6 +4329,8 @@ static CURLcode servercert(struct Curl_cfilter *cf,
|
4258 | 4329 | infof(data, " SSL certificate verify ok.");
|
4259 | 4330 | }
|
4260 | 4331 |
|
| 4332 | + infof_certstack(data, backend->handle); |
| 4333 | + |
4261 | 4334 | #if (OPENSSL_VERSION_NUMBER >= 0x0090808fL) && !defined(OPENSSL_NO_TLSEXT) && \
|
4262 | 4335 | !defined(OPENSSL_NO_OCSP)
|
4263 | 4336 | if(conn_config->verifystatus) {
|
|
0 commit comments