Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
grpc-web-go-client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
grpc-web-go-client
Commits
2ed1fec7
Commit
2ed1fec7
authored
Dec 21, 2022
by
Jonah Husson
Browse files
Options
Downloads
Plain Diff
Merge branch 'hotfix/atomic-cert' into 'release'
Hotfix/atomic cert See merge request
!7
parents
527c45dd
436c7ab7
No related branches found
No related tags found
1 merge request
!7
Hotfix/atomic cert
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
grpcweb/grpcweb.go
+2
-2
2 additions, 2 deletions
grpcweb/grpcweb.go
grpcweb/grpcweb_test.go
+1
-1
1 addition, 1 deletion
grpcweb/grpcweb_test.go
grpcweb/transport/transport.go
+12
-27
12 additions, 27 deletions
grpcweb/transport/transport.go
with
15 additions
and
30 deletions
grpcweb/grpcweb.go
+
2
−
2
View file @
2ed1fec7
...
@@ -182,8 +182,8 @@ func (c *ClientConn) applyCallOptions(opts []CallOption) *callOptions {
...
@@ -182,8 +182,8 @@ func (c *ClientConn) applyCallOptions(opts []CallOption) *callOptions {
return
&
callOptions
return
&
callOptions
}
}
func
(
c
*
ClientConn
)
GetRe
ceived
Certificate
()
(
*
x509
.
Certificate
,
error
)
{
func
(
c
*
ClientConn
)
GetRe
mote
Certificate
()
(
*
x509
.
Certificate
,
error
)
{
return
c
.
transport
.
GetRe
ceived
Certificate
()
return
c
.
transport
.
GetRe
mote
Certificate
()
}
}
// copied from rpc_util.go#msgHeader
// copied from rpc_util.go#msgHeader
...
...
This diff is collapsed.
Click to expand it.
grpcweb/grpcweb_test.go
+
1
−
1
View file @
2ed1fec7
...
@@ -28,7 +28,7 @@ type unaryTransport struct {
...
@@ -28,7 +28,7 @@ type unaryTransport struct {
err
error
err
error
}
}
func
(
t
*
unaryTransport
)
GetRe
ceived
Certificate
()
(
*
x509
.
Certificate
,
error
)
{
func
(
t
*
unaryTransport
)
GetRe
mote
Certificate
()
(
*
x509
.
Certificate
,
error
)
{
panic
(
"UNIMPLEMENTED"
)
panic
(
"UNIMPLEMENTED"
)
return
nil
,
nil
return
nil
,
nil
}
}
...
...
This diff is collapsed.
Click to expand it.
grpcweb/transport/transport.go
+
12
−
27
View file @
2ed1fec7
...
@@ -18,6 +18,7 @@ import (
...
@@ -18,6 +18,7 @@ import (
"strconv"
"strconv"
"strings"
"strings"
"sync"
"sync"
"sync/atomic"
"time"
"time"
)
)
...
@@ -25,7 +26,7 @@ import (
...
@@ -25,7 +26,7 @@ import (
type
UnaryTransport
interface
{
type
UnaryTransport
interface
{
Header
()
http
.
Header
Header
()
http
.
Header
Send
(
ctx
context
.
Context
,
endpoint
,
contentType
string
,
body
io
.
Reader
)
(
http
.
Header
,
[]
byte
,
error
)
Send
(
ctx
context
.
Context
,
endpoint
,
contentType
string
,
body
io
.
Reader
)
(
http
.
Header
,
[]
byte
,
error
)
GetRe
ceived
Certificate
()
(
*
x509
.
Certificate
,
error
)
GetRe
mote
Certificate
()
(
*
x509
.
Certificate
,
error
)
Close
()
error
Close
()
error
}
}
...
@@ -34,8 +35,7 @@ type httpTransport struct {
...
@@ -34,8 +35,7 @@ type httpTransport struct {
client
*
http
.
Client
client
*
http
.
Client
clientLock
*
sync
.
RWMutex
clientLock
*
sync
.
RWMutex
opts
*
ConnectOptions
opts
*
ConnectOptions
receivedCertLock
sync
.
RWMutex
receivedCertAtomic
atomic
.
Value
receivedCert
*
x509
.
Certificate
header
http
.
Header
header
http
.
Header
}
}
...
@@ -102,34 +102,19 @@ func (t *httpTransport) Send(ctx context.Context, endpoint, contentType string,
...
@@ -102,34 +102,19 @@ func (t *httpTransport) Send(ctx context.Context, endpoint, contentType string,
if
res
.
TLS
!=
nil
{
if
res
.
TLS
!=
nil
{
if
res
.
TLS
.
PeerCertificates
!=
nil
&&
len
(
res
.
TLS
.
PeerCertificates
)
>
0
{
if
res
.
TLS
.
PeerCertificates
!=
nil
&&
len
(
res
.
TLS
.
PeerCertificates
)
>
0
{
serverCert
:=
res
.
TLS
.
PeerCertificates
[
0
]
serverCert
:=
res
.
TLS
.
PeerCertificates
[
0
]
t
.
receivedCertLock
.
RLock
()
t
.
receivedCertAtomic
.
Store
(
serverCert
)
newCert
:=
t
.
receivedCert
==
nil
||
!
certsEqual
(
t
.
receivedCert
,
serverCert
)
t
.
receivedCertLock
.
RUnlock
()
if
newCert
{
t
.
receivedCertLock
.
Lock
()
stillNewCert
:=
t
.
receivedCert
==
nil
||
!
certsEqual
(
t
.
receivedCert
,
serverCert
)
if
stillNewCert
{
t
.
receivedCert
=
serverCert
}
t
.
receivedCertLock
.
Unlock
()
}
}
}
}
}
return
res
.
Header
,
respBody
,
nil
return
res
.
Header
,
respBody
,
nil
}
}
func
(
t
*
httpTransport
)
GetReceivedCertificate
()
(
*
x509
.
Certificate
,
error
)
{
func
(
t
*
httpTransport
)
GetRemoteCertificate
()
(
*
x509
.
Certificate
,
error
)
{
t
.
receivedCertLock
.
RLock
()
receivedCert
:=
t
.
receivedCertAtomic
.
Load
()
defer
t
.
receivedCertLock
.
RUnlock
()
if
receivedCert
==
nil
{
if
t
.
receivedCert
==
nil
{
return
nil
,
errors
.
New
(
"http transport has not yet received a tls certificate"
)
return
nil
,
errors
.
New
(
"http transport has not yet received a tls certificate"
)
}
}
return
t
.
receivedCert
,
nil
return
receivedCert
.
(
*
x509
.
Certificate
),
nil
}
func
certsEqual
(
c1
,
c2
*
x509
.
Certificate
)
bool
{
return
c1
.
Issuer
.
String
()
==
c2
.
Issuer
.
String
()
&&
c1
.
SerialNumber
==
c2
.
SerialNumber
}
}
// Close the httpTransport object
// Close the httpTransport object
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment