Skip to content

Commit

Permalink
fix(cert): skip secure verify still parse cert
Browse files Browse the repository at this point in the history
Signed-off-by: Jiyong Huang <huangjy@emqx.io>
  • Loading branch information
ngjaying committed Dec 19, 2024
1 parent e9e1e51 commit 0d45ac1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
6 changes: 1 addition & 5 deletions pkg/cert/cert.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 EMQ Technologies Co., Ltd.
// Copyright 2023-2024 EMQ Technologies Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -170,10 +170,6 @@ func GenerateTLSForClient(
Renegotiation: getRenegotiationSupport(Opts.RenegotiationSupport),
MinVersion: getTLSMinVersion(Opts.TLSMinVersion),
}
if tlsConfig.InsecureSkipVerify {
return tlsConfig, nil
}

if !isCertDefined(Opts) {
tlsConfig.Certificates = nil
} else {
Expand Down
22 changes: 16 additions & 6 deletions pkg/cert/cert_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2024 EMQ Technologies Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cert

import (
Expand Down Expand Up @@ -175,12 +189,8 @@ func TestGenerateTLSForClient(t *testing.T) {
TLSMinVersion: "",
},
},
want: &tls.Config{
InsecureSkipVerify: true,
MinVersion: tls.VersionTLS12,
Renegotiation: tls.RenegotiateNever,
},
wantErr: false,
want: nil,
wantErr: true,
},
}
for _, tt := range tests {
Expand Down

0 comments on commit 0d45ac1

Please sign in to comment.