Skip to content

Commit

Permalink
Merge pull request #27 from negz/dir-me-maybe
Browse files Browse the repository at this point in the history
Allow falling through to the Insecure option
  • Loading branch information
negz authored Sep 20, 2023
2 parents d5438af + 51c94be commit a4ada4f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ func Listen(network, address string) ServeOption {
// well as a CA certificate (ca.crt) that will be used to authenticate clients.
func MTLSCertificates(dir string) ServeOption {
return func(o *ServeOptions) error {
if dir == "" {
// We want to support passing both MTLSCertificates and
// Insecure as they were supplied as flags. So we don't
// want this to fail because no dir was supplied.
// If no TLS dir is supplied and insecure is false we'll
// return an error due to having no credentials specified.
return nil
}
crt, err := tls.LoadX509KeyPair(
filepath.Clean(filepath.Join(dir, "tls.crt")),
filepath.Clean(filepath.Join(dir, "tls.key")),
Expand Down

0 comments on commit a4ada4f

Please sign in to comment.