Skip to content

Commit fddda40

Browse files
committed
add validation to client rawCerts
1 parent d669d38 commit fddda40

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

cns/service.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ func getTLSConfig(tlsSettings localtls.TlsSettings, errChan chan<- error) (*tls.
158158

159159
// verifyPeerCertificate verifies the client certificate's subject name matches the expected subject name.
160160
func verifyPeerCertificate(rawCerts [][]byte, clientSubjectName string) error {
161+
162+
if len(rawCerts) == 0 {
163+
return errors.New("no client certificate provided")
164+
}
161165
// no client subject name provided, skip verification
162166
if clientSubjectName == "" {
163167
return nil

cns/service_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ func TestNewService(t *testing.T) {
176176
},
177177
}
178178

179-
tlsUrl := fmt.Sprintf("https://localhost:%s", tlsSettings.TLSPort)
179+
tlsURL := fmt.Sprintf("https://localhost:%s", tlsSettings.TLSPort)
180180
// TLS listener
181-
req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, tlsUrl, http.NoBody)
181+
req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, tlsURL, http.NoBody)
182182
require.NoError(t, err)
183183
resp, err := client.Do(req)
184184
t.Cleanup(func() {

0 commit comments

Comments
 (0)