Skip to content

Commit 8e98356

Browse files
committed
fix: create-certs.sh
1 parent 04d4c43 commit 8e98356

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

deploy/certs-utils/create-certs.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ function create_certs() {
3535
docker load -i "$BASE/down/cfssl-utils-$CFSSL_VER.tar" > /dev/null
3636

3737
# clean
38-
docker ps -a --format="{{ .Names }}"|grep cfssl-utils > /dev/null && \
3938
logger info "save current certs in backup" && \
4039
cp -r "$BASE/certs" "$BASE/backup/certs.$(date +'%Y%m%d%H%M%S')" && \
4140
logger info "stop&remove container: cfssl-utils" && \
@@ -58,11 +57,14 @@ function create_certs() {
5857
logger info "create agent.pem/agent-key.pem..."
5958
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'
6059

60+
logger info "stop&remove container: cfssl-utils" && \
61+
docker rm -f cfssl-utils > /dev/null
6162
}
6263

6364

6465
BASE=$(cd "$(dirname "$0")"; pwd)
6566
cd "$BASE"
6667
mkdir -p "$BASE/down" "$BASE/certs" "$BASE/backup"
68+
cp -f "$BASE"/*.json "$BASE/certs/"
6769

6870
create_certs

deploy/server/config/allowed-agents.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ agents:
33
auth_key: NiIsInR5cCI6IkpXVCJ9
44
approved_cns:
55
- mtls-client
6+
- ezvpn-agent
67
- name: test-002
78
auth_key: Yk0sInR5cCxMIkp19CoK
89
approved_cns:
910
- mtls-client
11+
- ezvpn-agent

server/responder.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func GetRegister(c echo.Context) error {
9191
}
9292
}
9393
}
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)
9595
return Error(c, http.StatusUnauthorized, err)
9696
}
9797

@@ -101,18 +101,10 @@ func GetSession(c echo.Context) error {
101101
for _, agent := range config.AGENTS.Agents {
102102
// check if the key is valid
103103
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+
})
116108
}
117109
}
118110
}

0 commit comments

Comments
 (0)