17b94a
From 2b859d1a5499a215c8c37472d4fc7d7e4d70dac6 Mon Sep 17 00:00:00 2001
17b94a
From: Mohit Agrawal <moagrawal@redhat.com>
17b94a
Date: Tue, 31 Mar 2020 16:45:35 +0530
17b94a
Subject: [PATCH 360/362] rpc: Make ssl log more useful
17b94a
17b94a
Currently, ssl_setup_connection_params throws 4 messages for every
17b94a
rpc connection that irritates a user while reading the logs. The same
17b94a
info we can print in a single log with peerinfo to make it more
17b94a
useful.ssl_setup_connection_params try to load dh_param even user
17b94a
has not configured it and if a dh_param file is not available it throws
17b94a
a failure message.To avoid the message load dh_param only while the user
17b94a
has configured it.
17b94a
17b94a
> Change-Id: I9ddb57f86a3fa3e519180cb5d88828e59fe0e487
17b94a
> Fixes: #1141
17b94a
> Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
17b94a
> Cherry pick from commit 80dd8cceab3b860bf1bc2945c8e2d8d0b3913e48
17b94a
> Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/24270/
17b94a
17b94a
BUG: 1812824
17b94a
Change-Id: I9ddb57f86a3fa3e519180cb5d88828e59fe0e487
17b94a
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
17b94a
Reviewed-on: https://code.engineering.redhat.com/gerrit/196371
17b94a
Tested-by: RHGS Build Bot <nigelb@redhat.com>
17b94a
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
17b94a
---
17b94a
 rpc/rpc-transport/socket/src/socket.c | 46 ++++++++++++++++++++---------------
17b94a
 1 file changed, 26 insertions(+), 20 deletions(-)
17b94a
17b94a
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
17b94a
index f54ca83..65845ea 100644
17b94a
--- a/rpc/rpc-transport/socket/src/socket.c
17b94a
+++ b/rpc/rpc-transport/socket/src/socket.c
17b94a
@@ -4240,6 +4240,7 @@ ssl_setup_connection_params(rpc_transport_t *this)
17b94a
     char *cipher_list = DEFAULT_CIPHER_LIST;
17b94a
     char *dh_param = DEFAULT_DH_PARAM;
17b94a
     char *ec_curve = DEFAULT_EC_CURVE;
17b94a
+    gf_boolean_t dh_flag = _gf_false;
17b94a
 
17b94a
     priv = this->private;
17b94a
 
17b94a
@@ -4248,6 +4249,10 @@ ssl_setup_connection_params(rpc_transport_t *this)
17b94a
         return 0;
17b94a
     }
17b94a
 
17b94a
+    if (!priv->ssl_enabled && !priv->mgmt_ssl) {
17b94a
+        return 0;
17b94a
+    }
17b94a
+
17b94a
     priv->ssl_own_cert = DEFAULT_CERT_PATH;
17b94a
     if (dict_get_str(this->options, SSL_OWN_CERT_OPT, &optstr) == 0) {
17b94a
         if (!priv->ssl_enabled) {
17b94a
@@ -4294,27 +4299,25 @@ ssl_setup_connection_params(rpc_transport_t *this)
17b94a
             priv->crl_path = gf_strdup(optstr);
17b94a
     }
17b94a
 
17b94a
-    gf_log(this->name, priv->ssl_enabled ? GF_LOG_INFO : GF_LOG_DEBUG,
17b94a
-           "SSL support on the I/O path is %s",
17b94a
-           priv->ssl_enabled ? "ENABLED" : "NOT enabled");
17b94a
-    gf_log(this->name, priv->mgmt_ssl ? GF_LOG_INFO : GF_LOG_DEBUG,
17b94a
-           "SSL support for glusterd is %s",
17b94a
-           priv->mgmt_ssl ? "ENABLED" : "NOT enabled");
17b94a
-
17b94a
     if (!priv->mgmt_ssl) {
17b94a
-        if (!dict_get_int32(this->options, SSL_CERT_DEPTH_OPT, &cert_depth)) {
17b94a
-            gf_log(this->name, GF_LOG_INFO, "using certificate depth %d",
17b94a
-                   cert_depth);
17b94a
+        if (!dict_get_int32_sizen(this->options, SSL_CERT_DEPTH_OPT,
17b94a
+                                  &cert_depth)) {
17b94a
         }
17b94a
     } else {
17b94a
         cert_depth = this->ctx->ssl_cert_depth;
17b94a
-        gf_log(this->name, GF_LOG_INFO, "using certificate depth %d",
17b94a
-               cert_depth);
17b94a
     }
17b94a
-    if (!dict_get_str(this->options, SSL_CIPHER_LIST_OPT, &cipher_list)) {
17b94a
+    gf_log(this->name, priv->ssl_enabled ? GF_LOG_INFO : GF_LOG_DEBUG,
17b94a
+           "SSL support for MGMT is %s IO path is %s certificate depth is %d "
17b94a
+           "for peer %s",
17b94a
+           (priv->mgmt_ssl ? "ENABLED" : "NOT enabled"),
17b94a
+           (priv->ssl_enabled ? "ENABLED" : "NOT enabled"), cert_depth,
17b94a
+           this->peerinfo.identifier);
17b94a
+
17b94a
+    if (!dict_get_str_sizen(this->options, SSL_CIPHER_LIST_OPT, &cipher_list)) {
17b94a
         gf_log(this->name, GF_LOG_INFO, "using cipher list %s", cipher_list);
17b94a
     }
17b94a
-    if (!dict_get_str(this->options, SSL_DH_PARAM_OPT, &dh_param)) {
17b94a
+    if (!dict_get_str_sizen(this->options, SSL_DH_PARAM_OPT, &dh_param)) {
17b94a
+        dh_flag = _gf_true;
17b94a
         gf_log(this->name, GF_LOG_INFO, "using DH parameters %s", dh_param);
17b94a
     }
17b94a
     if (!dict_get_str(this->options, SSL_EC_CURVE_OPT, &ec_curve)) {
17b94a
@@ -4349,12 +4352,15 @@ ssl_setup_connection_params(rpc_transport_t *this)
17b94a
 #ifdef SSL_OP_NO_COMPRESSION
17b94a
         SSL_CTX_set_options(priv->ssl_ctx, SSL_OP_NO_COMPRESSION);
17b94a
 #endif
17b94a
-
17b94a
-        if ((bio = BIO_new_file(dh_param, "r")) == NULL) {
17b94a
-            gf_log(this->name, GF_LOG_INFO,
17b94a
-                   "failed to open %s, "
17b94a
-                   "DH ciphers are disabled",
17b94a
-                   dh_param);
17b94a
+        /* Upload file to bio wrapper only if dh param is configured
17b94a
+         */
17b94a
+        if (dh_flag) {
17b94a
+            if ((bio = BIO_new_file(dh_param, "r")) == NULL) {
17b94a
+                gf_log(this->name, GF_LOG_ERROR,
17b94a
+                       "failed to open %s, "
17b94a
+                       "DH ciphers are disabled",
17b94a
+                       dh_param);
17b94a
+            }
17b94a
         }
17b94a
 
17b94a
         if (bio != NULL) {
17b94a
-- 
17b94a
1.8.3.1
17b94a