Skip to content

Commit

Permalink
Merge pull request #22 from emmansun/main
Browse files Browse the repository at this point in the history
处理mutual_auth_spec example证书过期
  • Loading branch information
Trisia authored Oct 26, 2023
2 parents 91ad98f + 0994296 commit 8bd1797
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ jobs:

build:
runs-on: ubuntu-latest
strategy:
matrix:
goVer: ['1.16', '1.19', '1.21']
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.16
go-version: ${{ matrix.goVer }}

- name: Tidy
run: |
Expand Down
10 changes: 10 additions & 0 deletions example/client/mutual_auth_spec/ecdhe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ package main

import (
"fmt"
"time"

"gitee.com/Trisia/gotlcp/tlcp"
"github.com/emmansun/gmsm/smx509"
)

// 测试时服务器时间,防止证书过期
func runtimeTime() time.Time {
res, _ := time.Parse("2006-01-02 15:04:05", "2023-03-15 00:00:00")
return res
}

// 客户端双向身份认证
func main() {
loadCert()
Expand All @@ -22,6 +30,8 @@ func main() {
tlcp.ECDHE_SM4_CBC_SM3,
// 注意:不能出现 ECC 系列套件,否则服务端可能选择ECC系列套件。
},
Time: runtimeTime,
EnableDebug: true,
}
//// 兼容向量模式的密钥交换参数
//config.ClientECDHEParamsAsVector = true
Expand Down
14 changes: 12 additions & 2 deletions example/server/mutual_auth_spec/main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
package main

import (
"gitee.com/Trisia/gotlcp/tlcp"
"github.com/emmansun/gmsm/smx509"
"io"
"net"
"time"

"gitee.com/Trisia/gotlcp/tlcp"
"github.com/emmansun/gmsm/smx509"
)

// 测试时服务器时间,防止证书过期
func runtimeTime() time.Time {
res, _ := time.Parse("2006-01-02 15:04:05", "2023-03-15 00:00:00")
return res
}

// 服务端双向身份认证
func main() {
loadCert()
Expand All @@ -20,6 +28,8 @@ func main() {
tlcp.ECDHE_SM4_GCM_SM3, // 最高优先级
tlcp.ECC_SM4_CBC_SM3, // 最低优先级
},
Time: runtimeTime,
EnableDebug: true,
}
listen, err := tlcp.Listen("tcp", ":8450", config)
if err != nil {
Expand Down

0 comments on commit 8bd1797

Please sign in to comment.