Skip to content

Test for sslinline=true feature #1193

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions ssl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,45 @@ func TestSSLClientCertificates(t *testing.T) {
}
}

// Authenticate over SSL using inline client certificates
func TestSSLInlineClientCertificates(t *testing.T) {
maybeSkipSSLTests(t)
// Environment sanity check: should fail without SSL
checkSSLSetup(t, "sslmode=disable user=pqgossltest")

certpath, ok := os.LookupEnv("PQSSLCERTTEST_PATH")
if !ok {
t.Fatalf("PQSSLCERTTEST_PATH not present in environment")
}

sslcertBytes, err := os.ReadFile(filepath.Join(certpath, "postgresql.crt"))
if err != nil {
t.Fatal(err)
}
sslcert := string(sslcertBytes)

sslkeyBytes, err := os.ReadFile(filepath.Join(certpath, "postgresql.key"))
if err != nil {
t.Fatal(err)
}
sslkey := string(sslkeyBytes)

if db, err := openSSLConn(t, "sslmode=require user=pqgosslcert sslinline=true sslcert='"+sslcert+"' sslkey='"+sslkey+"'"); err != nil {
t.Fatal(err)
} else {
rows, err := db.Query("SELECT 1")
if err != nil {
t.Fatal(err)
}
if err := rows.Close(); err != nil {
t.Fatal(err)
}
if err := db.Close(); err != nil {
t.Fatal(err)
}
}
}

// Check that clint sends SNI data when `sslsni` is not disabled
func TestSNISupport(t *testing.T) {
t.Parallel()
Expand Down