summaryrefslogtreecommitdiff
path: root/lib/session.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2018-08-20 19:20:12 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2018-08-20 19:20:12 +0000
commita46e3d3a3aab8957934b949d05177ed1503b5f5e (patch)
tree0b9d13b9ad394477d566f01ba8e279c33711cc7c /lib/session.c
parenta42db538c3f01aa76e2c1a2affc39237840c2522 (diff)
parent07180a416731749883234f931ac18831ff38abbb (diff)
downloadgnutls-a46e3d3a3aab8957934b949d05177ed1503b5f5e.tar.gz
Merge branch 'rfc7250_cert-types' into 'master'
RFC7250 certificate type negotiation See merge request gnutls/gnutls!498
Diffstat (limited to 'lib/session.c')
-rw-r--r--lib/session.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/lib/session.c b/lib/session.c
index 1622b29764..5d862198b5 100644
--- a/lib/session.c
+++ b/lib/session.c
@@ -337,7 +337,7 @@ char *gnutls_session_get_desc(gnutls_session_t session)
{
gnutls_kx_algorithm_t kx;
const char *kx_str, *sign_str;
- unsigned type;
+ gnutls_certificate_type_t ctype_client, ctype_server;
char kx_name[64] = "";
char proto_name[32];
char _group_name[24];
@@ -423,17 +423,29 @@ char *gnutls_session_get_desc(gnutls_session_t session)
}
}
-
- type = gnutls_certificate_type_get(session);
- if (type == GNUTLS_CRT_X509 || type == GNUTLS_CRT_UNKNOWN)
- snprintf(proto_name, sizeof(proto_name), "%s",
- gnutls_protocol_get_name(get_num_version
- (session)));
- else
- snprintf(proto_name, sizeof(proto_name), "%s-%s",
- gnutls_protocol_get_name(get_num_version
- (session)),
- gnutls_certificate_type_get_name(type));
+ // Check whether we have negotiated certificate types
+ if (_gnutls_has_negotiate_ctypes(session)) {
+ // Get certificate types
+ ctype_client = gnutls_certificate_type_get2(session, GNUTLS_CTYPE_CLIENT);
+ ctype_server = gnutls_certificate_type_get2(session, GNUTLS_CTYPE_SERVER);
+
+ if (ctype_client == ctype_server) {
+ // print proto version, client/server cert type
+ snprintf(proto_name, sizeof(proto_name), "%s-%s",
+ gnutls_protocol_get_name(get_num_version(session)),
+ gnutls_certificate_type_get_name(ctype_client));
+ } else {
+ // print proto version, client cert type, server cert type
+ snprintf(proto_name, sizeof(proto_name), "%s-%s-%s",
+ gnutls_protocol_get_name(get_num_version(session)),
+ gnutls_certificate_type_get_name(ctype_client),
+ gnutls_certificate_type_get_name(ctype_server));
+ }
+ } else { // Assumed default certificate type (X.509)
+ snprintf(proto_name, sizeof(proto_name), "%s",
+ gnutls_protocol_get_name(get_num_version
+ (session)));
+ }
desc = gnutls_malloc(DESC_SIZE);
if (desc == NULL)