Skip to content

Commit

Permalink
Merge pull request #78 from anyu/min-tls-version-1.2
Browse files Browse the repository at this point in the history
Enforce minimum TLS version to be 1.2
  • Loading branch information
mdelillo authored Jun 24, 2019
2 parents 30a69e4 + c0617e7 commit e6410a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions credhub/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func httpsClient(insecureSkipVerify bool, rootCAs *x509.CertPool, cert *tls.Cert
PreferServerCipherSuites: true,
Certificates: certs,
RootCAs: rootCAs,
MinVersion: tls.VersionTLS12,
},
Proxy: http.ProxyFromEnvironment,
Dial: dialer,
Expand Down
13 changes: 13 additions & 0 deletions credhub/client_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package credhub_test

import (
"crypto/tls"
"crypto/x509"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -33,6 +34,18 @@ var _ = Describe("Client()", func() {
})
})

Context("TLS configuration", func() {
It("should require a minimum TLS version of 1.2", func() {
ch, err := New("https://example.com")
Expect(err).NotTo(HaveOccurred())
client := ch.Client()
transport := client.Transport.(*http.Transport)

tlsConfig := transport.TLSClientConfig
Expect(tlsConfig.MinVersion).To(Equal(uint16(tls.VersionTLS12)))
})
})

Context("With ClientCert", func() {
It("should return a http.Client with tls.Config with client cert", func() {
ch, err := New("https://example.com", ClientCert("./fixtures/auth-tls-cert.pem", "./fixtures/auth-tls-key.pem"))
Expand Down

0 comments on commit e6410a0

Please sign in to comment.