File tree Expand file tree Collapse file tree 3 files changed +10
-14
lines changed Expand file tree Collapse file tree 3 files changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,6 @@ function create_certs() {
35
35
docker load -i " $BASE /down/cfssl-utils-$CFSSL_VER .tar" > /dev/null
36
36
37
37
# clean
38
- docker ps -a --format=" {{ .Names }}" | grep cfssl-utils > /dev/null && \
39
38
logger info " save current certs in backup" && \
40
39
cp -r " $BASE /certs" " $BASE /backup/certs.$( date +' %Y%m%d%H%M%S' ) " && \
41
40
logger info " stop&remove container: cfssl-utils" && \
@@ -58,11 +57,14 @@ function create_certs() {
58
57
logger info " create agent.pem/agent-key.pem..."
59
58
docker exec -it cfssl-utils sh -c ' cd /certs && cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=mtls agent-csr.json | cfssljson -bare agent'
60
59
60
+ logger info " stop&remove container: cfssl-utils" && \
61
+ docker rm -f cfssl-utils > /dev/null
61
62
}
62
63
63
64
64
65
BASE=$( cd " $( dirname " $0 " ) " ; pwd)
65
66
cd " $BASE "
66
67
mkdir -p " $BASE /down" " $BASE /certs" " $BASE /backup"
68
+ cp -f " $BASE " /* .json " $BASE /certs/"
67
69
68
70
create_certs
Original file line number Diff line number Diff line change 3
3
auth_key : NiIsInR5cCI6IkpXVCJ9
4
4
approved_cns :
5
5
- mtls-client
6
+ - ezvpn-agent
6
7
- name : test-002
7
8
auth_key : Yk0sInR5cCxMIkp19CoK
8
9
approved_cns :
9
10
- mtls-client
11
+ - ezvpn-agent
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ func GetRegister(c echo.Context) error {
91
91
}
92
92
}
93
93
}
94
- err := fmt .Errorf ("failed to register: invalid auth key: %s " , key )
94
+ err := fmt .Errorf ("failed to register: invalid auth key(%s) or cert CN " , key )
95
95
return Error (c , http .StatusUnauthorized , err )
96
96
}
97
97
@@ -101,18 +101,10 @@ func GetSession(c echo.Context) error {
101
101
for _ , agent := range config .AGENTS .Agents {
102
102
// check if the key is valid
103
103
if key == agent .AuthKey {
104
- // check CN if mTLS is enabled
105
- if c .Request ().TLS != nil && len (c .Request ().TLS .PeerCertificates ) > 0 {
106
- cn := c .Request ().TLS .PeerCertificates [0 ].Subject .CommonName
107
- for _ , approved_cn := range agent .ApprovedCNs {
108
- if cn == approved_cn {
109
- log .Printf ("agent %s@%s registered" , agent .Name , c .RealIP ())
110
- return WebSocket (c , func (ws * websocket.Conn ) error {
111
- return tunnel (ws )
112
- })
113
- }
114
- }
115
- }
104
+ log .Printf ("agent %s@%s session established" , agent .Name , c .RealIP ())
105
+ return WebSocket (c , func (ws * websocket.Conn ) error {
106
+ return tunnel (ws )
107
+ })
116
108
}
117
109
}
118
110
}
You can’t perform that action at this time.
0 commit comments