-
Notifications
You must be signed in to change notification settings - Fork 18k
src/net/http: server.go ListenAndServeTLS will overwrite TLSConfig Certificates even when they are already set #69990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
I believe this is working as intended, don't pass non empty values if you don't want them to be used. Having the function ignore arguments would be more confusing. |
@seankhliao I guess my question would then be why have the check at all for certs? To me the check implies we didn't want to overwrite if there were already certs. What are your thoughts? |
This forces an error if no certs are provided anywhere. |
The error would be the same with or without the cert check though. It just goes through to To me that block says "If we don't have cert data and we provided cert data, set the certificates to the keypair provided". I have to imagine if we wanted to go in the conditional when we had existing cert data, we would append rather than overwrite. |
Go version
latest
Output of
go env
in your module/workspace:What did you do?
I set up a
TLSConfig
on ahttp.Server
that hadCertificates
filled out. Example:There is code here that seems to be checking if there is already certificates set and not to overwrite them.
The problem here is the if condition needs to be an AND not an OR. If we have already set certificates we NEVER want to overwrite them, even if the provided files are not empty. I would be happy to implement this fix just want to confirm it is indeed a problem.
Proposed fix:
if !configHasCert && (certFile != "" || keyFile != "") {
Please let me know if you need more clarification!
What did you see happen?
I see my certificates get overwritten in my TLSConfig even though there is a check for it.
What did you expect to see?
I expect my Certificates not to be overwritten regardless of the device cert file and private key file I provide. I wonder if another function that accepts noa rguments might be more clear in this case.
The text was updated successfully, but these errors were encountered: