Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
getty
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
getty
Commits
fb33e078
Unverified
Commit
fb33e078
authored
Aug 10, 2020
by
aliiohs
Committed by
GitHub
Aug 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tls test case (#45)
Co-authored-by:
aliiohs
<
renzhiyuan@wecash.net
>
parent
2c6d6463
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
0 deletions
+6
-0
config.go
demo/hello/tls/config.go
+1
-0
tls.go
tls.go
+5
-0
No files found.
demo/hello/tls/config.go
View file @
fb33e078
...
...
@@ -36,6 +36,7 @@ var (
EventListener
=
&
hello
.
MessageHandler
{}
)
// InitialSession init session
func
InitialSession
(
session
getty
.
Session
)
(
err
error
)
{
//session.SetCompressType(getty.CompressZip)
_
,
ok
:=
session
.
Conn
()
.
(
*
tls
.
Conn
)
...
...
tls.go
View file @
fb33e078
...
...
@@ -27,10 +27,12 @@ import (
perrors
"github.com/pkg/errors"
)
// TlsConfigBuilder tls config builder interface
type
TlsConfigBuilder
interface
{
BuildTlsConfig
()
(
*
tls
.
Config
,
error
)
}
// ServerTlsConfigBuilder impl TlsConfigBuilder for server
type
ServerTlsConfigBuilder
struct
{
ServerKeyCertChainPath
string
ServerPrivateKeyPath
string
...
...
@@ -38,6 +40,7 @@ type ServerTlsConfigBuilder struct {
ServerTrustCertCollectionPath
string
}
// BuildTlsConfig impl TlsConfigBuilder method
func
(
s
*
ServerTlsConfigBuilder
)
BuildTlsConfig
()
(
*
tls
.
Config
,
error
)
{
var
(
err
error
...
...
@@ -75,6 +78,7 @@ func (s *ServerTlsConfigBuilder) BuildTlsConfig() (*tls.Config, error) {
return
config
,
nil
}
// ClientTlsConfigBuilder impl TlsConfigBuilder for client
type
ClientTlsConfigBuilder
struct
{
ClientKeyCertChainPath
string
ClientPrivateKeyPath
string
...
...
@@ -82,6 +86,7 @@ type ClientTlsConfigBuilder struct {
ClientTrustCertCollectionPath
string
}
// BuildTlsConfig impl TlsConfigBuilder method
func
(
c
*
ClientTlsConfigBuilder
)
BuildTlsConfig
()
(
*
tls
.
Config
,
error
)
{
cert
,
err
:=
tls
.
LoadX509KeyPair
(
c
.
ClientTrustCertCollectionPath
,
c
.
ClientPrivateKeyPath
)
...
...
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