gmsm icon indicating copy to clipboard operation
gmsm copied to clipboard

使用单证书 -tags single_cert 编译报错

Open xuyang2 opened this issue 3 years ago • 2 comments

~/code/github.com/tjfoc/gmsm (master) $ git rev-parse --verify HEAD
96b99bd6b0605768d25563d3daf47fda334a3143

~/code/github.com/tjfoc/gmsm (master) $ go build -tags single_cert ./...
# github.com/tjfoc/gmsm/gmtls
gmtls/gm_handshake_client_double.go:23:6: clientHandshakeStateGM redeclared in this block
        previous declaration at gmtls/gm_handshake_client.go:25:6
gmtls/gm_handshake_client_double.go:33:6: makeClientHelloGM redeclared in this block
        previous declaration at gmtls/gm_handshake_client.go:35:58
gmtls/gm_handshake_client_double.go:68:35: (*clientHandshakeStateGM).handshake redeclared in this block
        previous declaration at gmtls/gm_handshake_client.go:69:6
gmtls/gm_handshake_client_double.go:161:35: (*clientHandshakeStateGM).pickCipherSuite redeclared in this block
        previous declaration at gmtls/gm_handshake_client.go:162:6
gmtls/gm_handshake_client_double.go:171:35: (*clientHandshakeStateGM).doFullHandshake redeclared in this block
        previous declaration at gmtls/gm_handshake_client.go:172:6
gmtls/gm_handshake_client_double.go:395:35: (*clientHandshakeStateGM).establishKeys redeclared in this block
        previous declaration at gmtls/gm_handshake_client.go:401:6
gmtls/gm_handshake_client_double.go:417:35: (*clientHandshakeStateGM).serverResumedSession redeclared in this block
        previous declaration at gmtls/gm_handshake_client.go:423:6
gmtls/gm_handshake_client_double.go:424:35: (*clientHandshakeStateGM).processServerHello redeclared in this block
        previous declaration at gmtls/gm_handshake_client.go:430:6
gmtls/gm_handshake_client_double.go:497:35: (*clientHandshakeStateGM).readFinished redeclared in this block
        previous declaration at gmtls/gm_handshake_client.go:503:6
gmtls/gm_handshake_client_double.go:526:35: (*clientHandshakeStateGM).readSessionTicket redeclared in this block
        previous declaration at gmtls/gm_handshake_client.go:532:6
gmtls/gm_handshake_client_double.go:526:35: too many errors

~/code/github.com/tjfoc/gmsm (master) $ go version
go version go1.15.15 linux/amd64

xuyang2 avatar Jan 12 '22 03:01 xuyang2

gmtls/gm_handshake_client_double.go 加上 // +build !single_cert 之后, 编译仍然报错:

~/code/github.com/tjfoc/gmsm (master) $ go build -tags single_cert ./...
# github.com/tjfoc/gmsm/gmtls
gmtls/auto_handshake_server.go:172:10: cannot use []Certificate literal (type []Certificate) as type *Certificate in assignment
gmtls/auto_handshake_server.go:175:26: invalid operation: hs.cert[0] (type *Certificate does not support indexing)

gmtls/gm_handshake_server.go 和 gmtls/gm_handshake_server_double.go 中 的 type serverHandshakeStateGM structcert 字段定义不一样。 一个是 cert *Certificate 一个是 cert []Certificate

见: https://github.com/tjfoc/gmsm/blob/96b99bd6b0605768d25563d3daf47fda334a3143/gmtls/gm_handshake_server.go#L25-L36

https://github.com/tjfoc/gmsm/blob/96b99bd6b0605768d25563d3daf47fda334a3143/gmtls/gm_handshake_server_double.go#L25-L36

xuyang2 avatar Jan 12 '22 03:01 xuyang2

你这个国密tls调试通过了吗

Nu1i avatar Jul 05 '23 05:07 Nu1i