Skip to content

Don't panic in SSL code #734

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

Merged
merged 1 commit into from
Mar 27, 2018
Merged

Don't panic in SSL code #734

merged 1 commit into from
Mar 27, 2018

Conversation

ainar-g
Copy link
Contributor

@ainar-g ainar-g commented Mar 24, 2018

This change removes panics from SSL code. This is a part of the ongoing process of removing panics from lib/pq code.

Refs #681.

@ainar-g ainar-g force-pushed the nopanicssl branch 2 times, most recently from e07bd0f to dac763b Compare March 24, 2018 20:19
ssl.go Outdated
@@ -12,7 +12,7 @@ import (

// ssl generates a function to upgrade a net.Conn based on the "sslmode" and
// related settings. The function is nil when no upgrade should take place.
func ssl(o values) func(net.Conn) net.Conn {
func ssl(o values) (f func(net.Conn) (net.Conn, error), err error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the reason to use a named return here? I don't see one. Ditto below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

ssl.go Outdated
@@ -31,7 +31,7 @@ func ssl(o values) func(net.Conn) net.Conn {
// behavior is discouraged, and applications that need certificate
// validation should always use verify-ca or verify-full.
if sslrootcert, ok := o["sslrootcert"]; ok {
if _, err := os.Stat(sslrootcert); err == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should stay since the err here is definitely not the same as the one in the return.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

This change removes panics from SSL code. This is a part of the ongoing
process of removing panics from lib/pq code.

Refs lib#681.
@ainar-g
Copy link
Contributor Author

ainar-g commented Mar 27, 2018

@mjibson PTAL.

@maddyblue maddyblue merged commit d34b9ff into lib:master Mar 27, 2018
@cbandy
Copy link
Contributor

cbandy commented May 21, 2018

Quite late for a review, but I wanted to mention that this line is partly why I left the panics alone:

f4fe587

#525 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants