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