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

Catch failure for AppendCertsFromPEM #2

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
8 changes: 6 additions & 2 deletions rootcerts_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package rootcerts

import (
"crypto/x509"
"fmt"
"os/exec"
"path"

"github.com/mitchellh/go-homedir"
homedir "github.com/mitchellh/go-homedir"
)

// LoadSystemCAs has special behavior on Darwin systems to work around
Expand All @@ -29,7 +30,10 @@ func addCertsFromKeychain(pool *x509.CertPool, keychain string) error {
return err
}

pool.AppendCertsFromPEM(data)
if ok := pool.AppendCertsFromPEM(data); !ok {
// https://github.com/golang/go/issues/23711
return fmt.Errorf("Failed to add cert from %s. Is the common name a DNS compatible name?", keychain)
}

return nil
}
Expand Down