From 912d089a36f93a14de6423146df49c68510ef4b6 Mon Sep 17 00:00:00 2001 From: jbhusson <jonah@elixxir.io> Date: Wed, 21 Dec 2022 15:34:22 -0500 Subject: [PATCH] Use atomic cert for remote, rename to getremotecertificate --- connect/connection.go | 2 +- connect/connection_test.go | 2 +- connect/grpcConn.go | 4 ++-- connect/host.go | 6 +++--- connect/webConn.go | 6 +++--- go.mod | 2 +- go.sum | 4 ++++ 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/connect/connection.go b/connect/connection.go index 24a63cf..9499d9d 100644 --- a/connect/connection.go +++ b/connect/connection.go @@ -53,7 +53,7 @@ type Connection interface { IsOnline() (time.Duration, bool) - GetServerCert() (*x509.Certificate, error) + GetRemoteCertificate() (*x509.Certificate, error) clientConnHelpers } diff --git a/connect/connection_test.go b/connect/connection_test.go index 1f5cd75..6e27fbb 100644 --- a/connect/connection_test.go +++ b/connect/connection_test.go @@ -214,7 +214,7 @@ func TestWebConnection_TLS(t *testing.T) { t.Errorf("Did not receive expected payload") } - _, err = h.GetServerCert() + _, err = h.GetRemoteCertificate() if err != nil { t.Errorf("Did not receive cert: %+v", err) } diff --git a/connect/grpcConn.go b/connect/grpcConn.go index c23d76c..4449203 100644 --- a/connect/grpcConn.go +++ b/connect/grpcConn.go @@ -41,8 +41,8 @@ func (gc *grpcConn) IsWeb() bool { return false } -// GetServerCert returns an error on grpc hosts -func (gc *grpcConn) GetServerCert() (*x509.Certificate, error) { +// GetRemoteCertificate returns an error on grpc hosts +func (gc *grpcConn) GetRemoteCertificate() (*x509.Certificate, error) { return nil, errors.New("GetServerCert not implemented for GRPC hosts") } diff --git a/connect/host.go b/connect/host.go index c98ab05..2081ea7 100644 --- a/connect/host.go +++ b/connect/host.go @@ -216,11 +216,11 @@ func (h *Host) IsWeb() bool { return h.connection.IsWeb() } -// GetServerCert returns the tls certificate from the server for web hosts +// GetRemoteCertificate returns the tls certificate from the server for web hosts // Note that this will return an error when used on grpc hosts, and will not // have a certificate ready until something has been sent over the connection. -func (h *Host) GetServerCert() (*x509.Certificate, error) { - return h.connection.GetServerCert() +func (h *Host) GetRemoteCertificate() (*x509.Certificate, error) { + return h.connection.GetRemoteCertificate() } // SetMetricsTesting sets the host metrics to an arbitrary value. Used for testing diff --git a/connect/webConn.go b/connect/webConn.go index 54a0b69..066cae5 100644 --- a/connect/webConn.go +++ b/connect/webConn.go @@ -67,9 +67,9 @@ func (wc *webConn) IsWeb() bool { return true } -// GetServerCert returns the server tls certificate stored by the web connection -func (wc *webConn) GetServerCert() (*x509.Certificate, error) { - return wc.connection.GetReceivedCertificate() +// GetRemoteCertificate returns the server tls certificate stored by the web connection +func (wc *webConn) GetRemoteCertificate() (*x509.Certificate, error) { + return wc.connection.GetRemoteCertificate() } // connectWebHelper initializes the grpcweb ClientConn object diff --git a/go.mod b/go.mod index 7a33568..4d356cf 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module gitlab.com/xx_network/comms go 1.19 require ( - git.xx.network/elixxir/grpc-web-go-client v0.0.0-20221220161254-68bee4d4a516 + git.xx.network/elixxir/grpc-web-go-client v0.0.0-20221221203224-436c7ab720af github.com/golang/protobuf v1.5.2 github.com/improbable-eng/grpc-web v0.15.0 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index ada9e9c..7bcb3bb 100644 --- a/go.sum +++ b/go.sum @@ -5,6 +5,10 @@ git.xx.network/elixxir/grpc-web-go-client v0.0.0-20221220131901-1a7cdcec1831 h1: git.xx.network/elixxir/grpc-web-go-client v0.0.0-20221220131901-1a7cdcec1831/go.mod h1:uFKw2wmgtlYMdiIm08dM0Vj4XvX9ZKVCj71c8O7SAPo= git.xx.network/elixxir/grpc-web-go-client v0.0.0-20221220161254-68bee4d4a516 h1:Z1AimDI/+3ZZGcmkQaprDKiDn8oGmha7yyPvkDzIuMI= git.xx.network/elixxir/grpc-web-go-client v0.0.0-20221220161254-68bee4d4a516/go.mod h1:uFKw2wmgtlYMdiIm08dM0Vj4XvX9ZKVCj71c8O7SAPo= +git.xx.network/elixxir/grpc-web-go-client v0.0.0-20221221203031-c72e32187f30 h1:BpAfpIbpCNIkrUyLajIq+ymrsgKXoc3N930mdQ2OfLQ= +git.xx.network/elixxir/grpc-web-go-client v0.0.0-20221221203031-c72e32187f30/go.mod h1:uFKw2wmgtlYMdiIm08dM0Vj4XvX9ZKVCj71c8O7SAPo= +git.xx.network/elixxir/grpc-web-go-client v0.0.0-20221221203224-436c7ab720af h1:ogiu6sKbFjsKaMnmYSlflJDf973v4TVtBDSnUR2vEPQ= +git.xx.network/elixxir/grpc-web-go-client v0.0.0-20221221203224-436c7ab720af/go.mod h1:uFKw2wmgtlYMdiIm08dM0Vj4XvX9ZKVCj71c8O7SAPo= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -- GitLab