Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-tls
Commits
80317ea1
Commit
80317ea1
authored
Nov 24, 2019
by
Marten Seemann
Committed by
Steven Allen
Jan 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
close the underlying connection when the handshake fails
parent
66963cfa
Pipeline
#646
failed with stages
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
transport.go
transport.go
+10
-2
No files found.
transport.go
View file @
80317ea1
...
...
@@ -54,7 +54,11 @@ var _ cs.Transport = &Transport{}
// SecureInbound runs the TLS handshake as a server.
func
(
t
*
Transport
)
SecureInbound
(
ctx
context
.
Context
,
insecure
net
.
Conn
)
(
cs
.
Conn
,
error
)
{
config
,
keyCh
:=
t
.
identity
.
ConfigForAny
()
return
t
.
handshake
(
ctx
,
tls
.
Server
(
insecure
,
config
),
keyCh
)
cs
,
err
:=
t
.
handshake
(
ctx
,
tls
.
Server
(
insecure
,
config
),
keyCh
)
if
err
!=
nil
{
insecure
.
Close
()
}
return
cs
,
err
}
// SecureOutbound runs the TLS handshake as a client.
...
...
@@ -66,7 +70,11 @@ func (t *Transport) SecureInbound(ctx context.Context, insecure net.Conn) (cs.Co
// notice this after 1 RTT when calling Read.
func
(
t
*
Transport
)
SecureOutbound
(
ctx
context
.
Context
,
insecure
net
.
Conn
,
p
peer
.
ID
)
(
cs
.
Conn
,
error
)
{
config
,
keyCh
:=
t
.
identity
.
ConfigForPeer
(
p
)
return
t
.
handshake
(
ctx
,
tls
.
Client
(
insecure
,
config
),
keyCh
)
cs
,
err
:=
t
.
handshake
(
ctx
,
tls
.
Client
(
insecure
,
config
),
keyCh
)
if
err
!=
nil
{
insecure
.
Close
()
}
return
cs
,
err
}
func
(
t
*
Transport
)
handshake
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment