Draft
Conversation
4b72a4b to
96e0bd2
Compare
| func defaultBMCTransport() *http.Transport { | ||
| return &http.Transport{ | ||
| //nolint:gosec // BMCs use self-signed certs | ||
| TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, |
Check failure
Code scanning / CodeQL
Disabled TLS certificate check
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to ensure that TLS certificate verification is enabled. This can be done by setting InsecureSkipVerify to false and properly configuring the application to trust the self-signed certificates used by the BMCs. This involves adding the self-signed certificates to the application's trusted certificate pool.
- Modify the
defaultBMCTransportfunction to setInsecureSkipVerifytofalse. - Load the self-signed certificates and add them to the
RootCAsof thetls.Config.
Suggested changeset
1
internal/flipflop/validation_client.go
| @@ -8,2 +8,5 @@ | ||
| "crypto/tls" | ||
| "crypto/x509" | ||
| "io/ioutil" | ||
| "log" | ||
| "net" | ||
| @@ -20,5 +23,17 @@ | ||
| func defaultBMCTransport() *http.Transport { | ||
| // Load self-signed certificates | ||
| certPool := x509.NewCertPool() | ||
| cert, err := ioutil.ReadFile("/path/to/self-signed-cert.pem") | ||
| if err != nil { | ||
| log.Fatalf("Failed to read self-signed certificate: %v", err) | ||
| } | ||
| if ok := certPool.AppendCertsFromPEM(cert); !ok { | ||
| log.Fatalf("Failed to append self-signed certificate to pool") | ||
| } | ||
|
|
||
| return &http.Transport{ | ||
| //nolint:gosec // BMCs use self-signed certs | ||
| TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, | ||
| TLSClientConfig: &tls.Config{ | ||
| InsecureSkipVerify: false, | ||
| RootCAs: certPool, | ||
| }, | ||
| DisableKeepAlives: true, |
Copilot is powered by AI and may make mistakes. Always verify output.
96e0bd2 to
894b95f
Compare
I imported a pre-release version of bmclib to get access to the new versions of the supermicro client object. Using that I defined some minimalist interfaces and used mockery to provide test collateral.
894b95f to
0f28e86
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
From Vince: