Skip to content
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

skip TLS check for detecting layer data #256

Closed
wants to merge 2 commits into from

Conversation

supereagle
Copy link
Contributor

This skips TLS check for detecting layer data from Server
configured with TLS.

Fixes #251

@supereagle
Copy link
Contributor Author

@Quentin-M PTAL. Thanks!

@jzelinskie
Copy link
Contributor

Disabling these checks should be behind a flag if we're going to support it because defaulting to this behavior is dangerous. You should be adding your certificates to the system root (and mounting that into a container).

@supereagle
Copy link
Contributor Author

@jzelinskie Thanks for your review and advice.

Yes. Users can avoid this error by adding the certificates. But if the layer data is from several different servers, this way maybe is not so convenient. At the same time, it will restrict the container to run anywhere.

Adding a flag to control TLS check is a good way. I think we can add a flag Insecure in the body of POST Layer API, as TLS check is only used for detecting layer data in this REST API. Make the users can dynamically control the TLS check by themselves when call this API, and the default is to enable TLS check.

@supereagle
Copy link
Contributor Author

@jzelinskie @Quentin-M Whether we need to add a flag to support disabling this check?

@jzelinskie
Copy link
Contributor

@supereagle I would not be opposed to adding a flag to the binary for testing called --insecure-tls that disabled this across the board.

@jzelinskie jzelinskie added area/usability related to improving user experience component/config kind/design relates to the fundamental design of a component reviewed/needs rework will be closed if review not addressed labels Nov 11, 2016
@supereagle
Copy link
Contributor Author

@jzelinskie Is the flag --insecure-tls just for testing? Why not for production?

@jzelinskie
Copy link
Contributor

@supereagle For TLS to be secure, it needs to use PKI rather than blindly trusting any certificate it sees. People should be able to run Clair without verifying certificates, but if they want run it in that mode, they should be forced to acknowledge that it's insecure.

@supereagle
Copy link
Contributor Author

@jzelinskie Thanks. I will add this flag.

@supereagle
Copy link
Contributor Author

@jzelinskie Have added the flag --insecure-tls. PTAL, thanks.

@supereagle
Copy link
Contributor Author

@jzelinskie Any comments about the new work in this PR?

@jzelinskie
Copy link
Contributor

I'm not 100% convinced that this API needs enable dynamic toggling of functionality. thoughts @Quentin-M ?

@jzelinskie
Copy link
Contributor

This needs a rebase.
Also follow-up ping @Quentin-M for thoughts

@@ -57,6 +58,7 @@ func main() {
flagConfigPath := flag.String("config", "/etc/clair/config.yaml", "Load configuration from the specified file.")
flagCPUProfilePath := flag.String("cpu-profile", "", "Write a CPU profile to the specified file before exiting.")
flagLogLevel := flag.String("log-level", "info", "Define the logging level.")
flagInsecureTLS := flag.Bool("insecure-tls", false, "Disable TLS check when detect the data of layers.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disable TLS server's certificate chain and host name verification when pulling layers

@@ -45,6 +46,10 @@ var (

// ErrCouldNotFindLayer is returned when we could not download or open the layer file.
ErrCouldNotFindLayer = cerrors.NewBadRequestError("could not find layer")

insecureTLSLock sync.Mutex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the mutex is overkill.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I will remove it.

@@ -45,6 +46,10 @@ var (

// ErrCouldNotFindLayer is returned when we could not download or open the layer file.
ErrCouldNotFindLayer = cerrors.NewBadRequestError("could not find layer")

insecureTLSLock sync.Mutex
// insecureTLS controls the TLS check when detect the data of layers, enabled in default.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insecureTLS controls whether TLS server's certificate chain and host name are verified when pulling layers

@@ -120,3 +129,10 @@ func DetectData(format, path string, headers map[string]string, toExtract []stri

return nil, cerrors.NewBadRequestError(fmt.Sprintf("unsupported image format '%s'", format))
}

// SetInsecureTLS sets the insecureTLS to control the TLS check when detect the data of layers.
func SetInsecureTLS(insecure bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not bother having a function if there is no mutex.

@Quentin-M
Copy link
Contributor

I understand the use-case and would be willing to merge this.
I don't feel like having an API-level toggle is worth at all though, flag is fine, I even thought for a second that a const overwritten at build time would be enough - but other users might actually want to use this.

@supereagle
Copy link
Contributor Author

supereagle commented Feb 25, 2017

Too many conflicts while rebasing. Create another PR #331. This PR can be closed.

@jzelinskie jzelinskie closed this Feb 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/usability related to improving user experience kind/design relates to the fundamental design of a component reviewed/needs rework will be closed if review not addressed
Development

Successfully merging this pull request may close these issues.

3 participants