From add7c2d2421158cccf39721ea2f85861681fcba0 Mon Sep 17 00:00:00 2001 From: Roy Lee Date: Sat, 14 May 2022 01:08:13 -0700 Subject: [PATCH] rpcclient: support SkipVerify of TLS certificate. --- rpcclient/infrastructure.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rpcclient/infrastructure.go b/rpcclient/infrastructure.go index 9923cbd1..9b93d739 100644 --- a/rpcclient/infrastructure.go +++ b/rpcclient/infrastructure.go @@ -1192,6 +1192,9 @@ type ConnConfig struct { // the wire in cleartext. DisableTLS bool + // SkipVerify instruct the client to skip verifying TLS certificate. + SkipVerify bool + // Certificates are the bytes for a PEM-encoded certificate chain used // for the TLS connection. It has no effect if the DisableTLS parameter // is true. @@ -1295,7 +1298,8 @@ func newHTTPClient(config *ConnConfig) (*http.Client, error) { pool := x509.NewCertPool() pool.AppendCertsFromPEM(config.Certificates) tlsConfig = &tls.Config{ - RootCAs: pool, + RootCAs: pool, + InsecureSkipVerify: config.SkipVerify, } } } @@ -1318,7 +1322,8 @@ func dial(config *ConnConfig) (*websocket.Conn, error) { var scheme = "ws" if !config.DisableTLS { tlsConfig = &tls.Config{ - MinVersion: tls.VersionTLS12, + MinVersion: tls.VersionTLS12, + InsecureSkipVerify: config.SkipVerify, } if len(config.Certificates) > 0 { pool := x509.NewCertPool() -- 2.45.3