Unverified Commit fb33e078 authored by aliiohs's avatar aliiohs Committed by GitHub

add tls test case (#45)

Co-authored-by: 's avataraliiohs <renzhiyuan@wecash.net>
parent 2c6d6463
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment