-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev testtls #16
base: master
Are you sure you want to change the base?
Dev testtls #16
Conversation
Signed-off-by: 陈桂军 <[email protected]>
Signed-off-by: 陈桂军 <[email protected]>
|
||
func main() { | ||
const address = "127.0.0.1:6443" | ||
const caFile = "../asserts/sm2-double-cert/CA.crt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里和上面用的文件目录名都叫 asserts,是想表达assets的意思么?还是就是断言
的意思?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以参考下 https://github.com/guoger/tape/blob/master/e2e/e2e_test.go 结合使用 "github.com/onsi/gomega/gexec"
库和fmt标准输出,优化一下我们的测试代码。(如果可能)
@@ -0,0 +1,5 @@ | |||
-----BEGIN PRIVATE KEY----- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果可以,避免在这里上传key
func clientRun(address, caFile, signCertFile, signKeyFile, encCertFile, encKeyFile string) { | ||
signCert, err := tls.LoadX509KeyPair(signCertFile, signKeyFile) | ||
if err != nil { | ||
log.Fatalf("Failed to load LoadX509KeyPair: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接error就报错了吧?
if err != nil { | ||
log.Fatalf("Failed to read num: %v, err:%v", n, err) | ||
} | ||
fmt.Printf("Receive server message: %s\n", string(buf[:n])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这行有必要么?对于测试程序?
log.Println(err) | ||
continue | ||
} | ||
go handleConn(conn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
考虑下一些golang的已经有的库,避免重复造轮子?以及作为示例程序会更好?
log.Println(err) | ||
return | ||
} | ||
fmt.Printf("Receive client message:%s\n", msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt 是否必要?
) | ||
|
||
func Test(t *testing.T) { | ||
end = make(chan bool, 64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
试试看 "github.com/onsi/gomega/gexec"
…S handshake Signed-off-by: 陈桂军 <[email protected]>
modify sm4.ReadKeyFromPem
添加支持测试tls单、双证书代码