|
|
dc8c34 |
From afe368b81ca436675b4a89596ab2ac73c838bd30 Mon Sep 17 00:00:00 2001
|
|
|
dc8c34 |
From: Noriko Hosoi <nhosoi@redhat.com>
|
|
|
dc8c34 |
Date: Wed, 7 Jan 2015 11:35:32 -0800
|
|
|
dc8c34 |
Subject: [PATCH 294/305] Ticket #47945 - Add SSL/TLS version info to the
|
|
|
dc8c34 |
access log
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Description: Added the currently used SSL library version info per
|
|
|
dc8c34 |
connection to the access log.
|
|
|
dc8c34 |
Sample output:
|
|
|
dc8c34 |
SSL
|
|
|
dc8c34 |
[..] conn=3 fd=64 slot=64 SSL connection from ::1 to ::1
|
|
|
dc8c34 |
[..] conn=3 TLS1.2 128-bit AES-GCM
|
|
|
dc8c34 |
|
|
|
dc8c34 |
startTLS
|
|
|
dc8c34 |
[..] conn=4 op=0 EXT oid="1.3.6.1.4.1.1466.20037" name="startTLS"
|
|
|
dc8c34 |
[..] conn=4 op=0 RESULT err=0 tag=120 nentries=0 etime=0
|
|
|
dc8c34 |
[..] conn=4 TLS1.2 128-bit AES-GCM
|
|
|
dc8c34 |
|
|
|
dc8c34 |
To convert the SSL version number to string (e.g., SSL_LIBRARY_VERSION_
|
|
|
dc8c34 |
TLS_1_2 --> "TLS1.2"), instead of maintaining a mapping table, this
|
|
|
dc8c34 |
patch calculates the number and generates the version string.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Back-ported commit a2e0de3aa90f04593427628afeb7fe090dac93fb
|
|
|
dc8c34 |
|
|
|
dc8c34 |
https://fedorahosted.org/389/ticket/47945
|
|
|
dc8c34 |
(cherry picked from commit d62b281480c4c17438a6541c150bdb1e80abf14f)
|
|
|
dc8c34 |
---
|
|
|
dc8c34 |
ldap/servers/slapd/auth.c | 115 ++++++++++++++++++++-----------------
|
|
|
dc8c34 |
ldap/servers/slapd/slapi-private.h | 19 ++++++
|
|
|
dc8c34 |
2 files changed, 80 insertions(+), 54 deletions(-)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/auth.c b/ldap/servers/slapd/auth.c
|
|
|
dc8c34 |
index 4976406..73f6c0e 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/auth.c
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/auth.c
|
|
|
dc8c34 |
@@ -433,6 +433,7 @@ handle_handshake_done (PRFileDesc *prfd, void* clientData)
|
|
|
dc8c34 |
SSLChannelInfo channelInfo;
|
|
|
dc8c34 |
SSLCipherSuiteInfo cipherInfo;
|
|
|
dc8c34 |
char* subject = NULL;
|
|
|
dc8c34 |
+ char sslversion[64];
|
|
|
dc8c34 |
|
|
|
dc8c34 |
if ( (slapd_ssl_getChannelInfo (prfd, &channelInfo, sizeof(channelInfo))) != SECSuccess ) {
|
|
|
dc8c34 |
PRErrorCode errorCode = PR_GetError();
|
|
|
dc8c34 |
@@ -465,59 +466,63 @@ handle_handshake_done (PRFileDesc *prfd, void* clientData)
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
+ (void) slapi_getSSLVersion_str(channelInfo.protocolVersion, sslversion, sizeof(sslversion));
|
|
|
dc8c34 |
if (config_get_SSLclientAuth() == SLAPD_SSLCLIENTAUTH_OFF ) {
|
|
|
dc8c34 |
- slapi_log_access (LDAP_DEBUG_STATS, "conn=%" NSPRIu64 " SSL %i-bit %s\n",
|
|
|
dc8c34 |
- conn->c_connid, keySize, cipher ? cipher : "NULL" );
|
|
|
dc8c34 |
+ slapi_log_access (LDAP_DEBUG_STATS, "conn=%" NSPRIu64 " %s %i-bit %s\n",
|
|
|
dc8c34 |
+ (long long unsigned int)conn->c_connid,
|
|
|
dc8c34 |
+ sslversion, keySize, cipher ? cipher : "NULL" );
|
|
|
dc8c34 |
goto done;
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
if (clientCert == NULL) {
|
|
|
dc8c34 |
- slapi_log_access (LDAP_DEBUG_STATS, "conn=%" NSPRIu64 " SSL %i-bit %s\n",
|
|
|
dc8c34 |
- conn->c_connid, keySize, cipher ? cipher : "NULL" );
|
|
|
dc8c34 |
+ slapi_log_access (LDAP_DEBUG_STATS, "conn=%" NSPRIu64 " %s %i-bit %s\n",
|
|
|
dc8c34 |
+ (long long unsigned int)conn->c_connid,
|
|
|
dc8c34 |
+ sslversion, keySize, cipher ? cipher : "NULL" );
|
|
|
dc8c34 |
} else {
|
|
|
dc8c34 |
- subject = subject_of (clientCert);
|
|
|
dc8c34 |
- if (!subject) {
|
|
|
dc8c34 |
- slapi_log_access( LDAP_DEBUG_STATS,
|
|
|
dc8c34 |
- "conn=%" NSPRIu64 " SSL %i-bit %s; missing subject\n",
|
|
|
dc8c34 |
- conn->c_connid, keySize, cipher ? cipher : "NULL");
|
|
|
dc8c34 |
- goto done;
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
- {
|
|
|
dc8c34 |
- char* issuer = issuer_of (clientCert);
|
|
|
dc8c34 |
- char sbuf[ BUFSIZ ], ibuf[ BUFSIZ ];
|
|
|
dc8c34 |
- slapi_log_access( LDAP_DEBUG_STATS,
|
|
|
dc8c34 |
- "conn=%" NSPRIu64 " SSL %i-bit %s; client %s; issuer %s\n",
|
|
|
dc8c34 |
- conn->c_connid, keySize, cipher ? cipher : "NULL",
|
|
|
dc8c34 |
- subject ? escape_string( subject, sbuf ) : "NULL",
|
|
|
dc8c34 |
- issuer ? escape_string( issuer, ibuf ) : "NULL");
|
|
|
dc8c34 |
- if (issuer) free (issuer);
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
- slapi_dn_normalize (subject);
|
|
|
dc8c34 |
- {
|
|
|
dc8c34 |
- LDAPMessage* chain = NULL;
|
|
|
dc8c34 |
- char *basedn = config_get_basedn();
|
|
|
dc8c34 |
- int err;
|
|
|
dc8c34 |
-
|
|
|
dc8c34 |
- err = ldapu_cert_to_ldap_entry
|
|
|
dc8c34 |
- (clientCert, internal_ld, basedn?basedn:""/*baseDN*/, &chain);
|
|
|
dc8c34 |
- if (err == LDAPU_SUCCESS && chain) {
|
|
|
dc8c34 |
- LDAPMessage* entry = slapu_first_entry (internal_ld, chain);
|
|
|
dc8c34 |
- if (entry) {
|
|
|
dc8c34 |
- /* clientDN is duplicated in slapu_get_dn */
|
|
|
dc8c34 |
- clientDN = slapu_get_dn (internal_ld, entry);
|
|
|
dc8c34 |
- } else {
|
|
|
dc8c34 |
-
|
|
|
dc8c34 |
- extraErrorMsg = "no entry";
|
|
|
dc8c34 |
- LDAPDebug (LDAP_DEBUG_TRACE, "<= ldapu_cert_to_ldap_entry() %s\n",
|
|
|
dc8c34 |
- extraErrorMsg, 0, 0);
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
- } else {
|
|
|
dc8c34 |
- extraErrorMsg = ldapu_err2string(err);
|
|
|
dc8c34 |
- LDAPDebug (LDAP_DEBUG_TRACE, "<= ldapu_cert_to_ldap_entry() %i (%s)%s\n",
|
|
|
dc8c34 |
- err, extraErrorMsg, chain ? "" : " NULL");
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
- slapi_ch_free_string(&basedn);
|
|
|
dc8c34 |
- slapu_msgfree (internal_ld, chain);
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
+ subject = subject_of (clientCert);
|
|
|
dc8c34 |
+ if (!subject) {
|
|
|
dc8c34 |
+ slapi_log_access( LDAP_DEBUG_STATS,
|
|
|
dc8c34 |
+ "conn=%" NSPRIu64 " %s %i-bit %s; missing subject\n",
|
|
|
dc8c34 |
+ (long long unsigned int)conn->c_connid,
|
|
|
dc8c34 |
+ sslversion, keySize, cipher ? cipher : "NULL");
|
|
|
dc8c34 |
+ goto done;
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ {
|
|
|
dc8c34 |
+ char* issuer = issuer_of (clientCert);
|
|
|
dc8c34 |
+ char sbuf[ BUFSIZ ], ibuf[ BUFSIZ ];
|
|
|
dc8c34 |
+ slapi_log_access( LDAP_DEBUG_STATS,
|
|
|
dc8c34 |
+ "conn=%" NSPRIu64 " %s %i-bit %s; client %s; issuer %s\n",
|
|
|
dc8c34 |
+ (long long unsigned int)conn->c_connid,
|
|
|
dc8c34 |
+ sslversion, keySize, cipher ? cipher : "NULL",
|
|
|
dc8c34 |
+ subject ? escape_string( subject, sbuf ) : "NULL",
|
|
|
dc8c34 |
+ issuer ? escape_string( issuer, ibuf ) : "NULL");
|
|
|
dc8c34 |
+ if (issuer) free (issuer);
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ slapi_dn_normalize (subject);
|
|
|
dc8c34 |
+ {
|
|
|
dc8c34 |
+ LDAPMessage* chain = NULL;
|
|
|
dc8c34 |
+ char *basedn = config_get_basedn();
|
|
|
dc8c34 |
+ int err;
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ err = ldapu_cert_to_ldap_entry
|
|
|
dc8c34 |
+ (clientCert, internal_ld, basedn?basedn:""/*baseDN*/, &chain);
|
|
|
dc8c34 |
+ if (err == LDAPU_SUCCESS && chain) {
|
|
|
dc8c34 |
+ LDAPMessage* entry = slapu_first_entry (internal_ld, chain);
|
|
|
dc8c34 |
+ if (entry) {
|
|
|
dc8c34 |
+ /* clientDN is duplicated in slapu_get_dn */
|
|
|
dc8c34 |
+ clientDN = slapu_get_dn (internal_ld, entry);
|
|
|
dc8c34 |
+ } else {
|
|
|
dc8c34 |
+ extraErrorMsg = "no entry";
|
|
|
dc8c34 |
+ LDAPDebug (LDAP_DEBUG_TRACE, "<= ldapu_cert_to_ldap_entry() %s\n",
|
|
|
dc8c34 |
+ extraErrorMsg, 0, 0);
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ } else {
|
|
|
dc8c34 |
+ extraErrorMsg = ldapu_err2string(err);
|
|
|
dc8c34 |
+ LDAPDebug (LDAP_DEBUG_TRACE, "<= ldapu_cert_to_ldap_entry() %i (%s)%s\n",
|
|
|
dc8c34 |
+ err, extraErrorMsg, chain ? "" : " NULL");
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ slapi_ch_free_string(&basedn);
|
|
|
dc8c34 |
+ slapu_msgfree (internal_ld, chain);
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
if (clientDN != NULL) {
|
|
|
dc8c34 |
@@ -525,14 +530,16 @@ handle_handshake_done (PRFileDesc *prfd, void* clientData)
|
|
|
dc8c34 |
sdn = slapi_sdn_new_dn_passin(clientDN);
|
|
|
dc8c34 |
clientDN = slapi_ch_strdup(slapi_sdn_get_dn(sdn));
|
|
|
dc8c34 |
slapi_sdn_free(&sdn;;
|
|
|
dc8c34 |
- slapi_log_access (LDAP_DEBUG_STATS,
|
|
|
dc8c34 |
- "conn=%" NSPRIu64 " SSL client bound as %s\n",
|
|
|
dc8c34 |
- conn->c_connid, clientDN);
|
|
|
dc8c34 |
+ slapi_log_access (LDAP_DEBUG_STATS,
|
|
|
dc8c34 |
+ "conn=%" NSPRIu64 " %s client bound as %s\n",
|
|
|
dc8c34 |
+ (long long unsigned int)conn->c_connid,
|
|
|
dc8c34 |
+ sslversion, clientDN);
|
|
|
dc8c34 |
} else if (clientCert != NULL) {
|
|
|
dc8c34 |
slapi_log_access (LDAP_DEBUG_STATS,
|
|
|
dc8c34 |
- "conn=%" NSPRIu64 " SSL failed to map client "
|
|
|
dc8c34 |
+ "conn=%" NSPRIu64 " %s failed to map client "
|
|
|
dc8c34 |
"certificate to LDAP DN (%s)\n",
|
|
|
dc8c34 |
- conn->c_connid, extraErrorMsg );
|
|
|
dc8c34 |
+ (long long unsigned int)conn->c_connid,
|
|
|
dc8c34 |
+ sslversion, extraErrorMsg);
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/*
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
|
|
|
dc8c34 |
index 8507f47..18f0e94 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/slapi-private.h
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/slapi-private.h
|
|
|
dc8c34 |
@@ -1278,6 +1278,25 @@ void modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods);
|
|
|
dc8c34 |
/* add.c */
|
|
|
dc8c34 |
void add_internal_modifiersname(Slapi_PBlock *pb, Slapi_Entry *e);
|
|
|
dc8c34 |
|
|
|
dc8c34 |
+/* ssl.c */
|
|
|
dc8c34 |
+/*
|
|
|
dc8c34 |
+ * If non NULL buf and positive bufsize is given,
|
|
|
dc8c34 |
+ * the memory is used to store the version string.
|
|
|
dc8c34 |
+ * Otherwise, the memory for the string is allocated.
|
|
|
dc8c34 |
+ * The latter case, caller is responsible to free it.
|
|
|
dc8c34 |
+ */
|
|
|
dc8c34 |
+/* vnum is supposed to be in one of the following:
|
|
|
dc8c34 |
+ * nss3/sslproto.h
|
|
|
dc8c34 |
+ * #define SSL_LIBRARY_VERSION_2 0x0002
|
|
|
dc8c34 |
+ * #define SSL_LIBRARY_VERSION_3_0 0x0300
|
|
|
dc8c34 |
+ * #define SSL_LIBRARY_VERSION_TLS_1_0 0x0301
|
|
|
dc8c34 |
+ * #define SSL_LIBRARY_VERSION_TLS_1_1 0x0302
|
|
|
dc8c34 |
+ * #define SSL_LIBRARY_VERSION_TLS_1_2 0x0303
|
|
|
dc8c34 |
+ * #define SSL_LIBRARY_VERSION_TLS_1_3 0x0304
|
|
|
dc8c34 |
+ * ...
|
|
|
dc8c34 |
+ */
|
|
|
dc8c34 |
+char *slapi_getSSLVersion_str(PRUint16 vnum, char *buf, size_t bufsize);
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
#ifdef __cplusplus
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
#endif
|
|
|
dc8c34 |
--
|
|
|
dc8c34 |
1.9.3
|
|
|
dc8c34 |
|