diff --git a/connect/connection.go b/connect/connection.go index 24a63cfbb76a81f60e5194a2d06251ade8a4be29..9499d9dd216bd15fce73aada589f62c92e2abf5a 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 1f5cd7595539ed05d27fe712e3fadb9d55b10121..6e27fbbb64cfe4fd7e17fbf633e80b453bd8fb16 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 c23d76c2a7527fe0fae57771d686250354c0a2ec..4449203e3bcbd866931a118a56879f2e84de57ef 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 c98ab054ffdcd8a98e54e751c4fcb3a66632511c..2081ea7dd67612f7ffeaa6d825ebf5382907dbfc 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 54a0b69ead7764a754742339c0d2054bc76b1e7a..066cae5cbd6e77bdb3ac3010fda80cebfbf0ad14 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 7a335684daacb5a365e711e56068c3ee05cce2fe..4d356cfcbf5d6d9af14cb1ac9ba00f1c5f25cfde 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 ada9e9cc156c4ce8a5f4a4971c18cfb1e56e6192..7bcb3bb39477ec95a525b9ee87741c004d4e4ea6 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=