Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Commit

Permalink
Add readCrt() function
Browse files Browse the repository at this point in the history
  • Loading branch information
chr4 committed Jun 14, 2016
1 parent 1a5c8b2 commit 8f09dac
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/acme/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ func readKey(path string) (*rsa.PrivateKey, error) {
return x509.ParsePKCS1PrivateKey(d.Bytes)
}

func readCrt(path string) (*x509.Certificate, error) {
b, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
d, _ := pem.Decode(b)
if d == nil {
return nil, fmt.Errorf("no block found in %q", path)
}
if d.Type != x509PublicKey {
return nil, fmt.Errorf("%q is unsupported", d.Type)
}
return x509.ParseCertificate(d.Bytes)
}

// writeKey writes k to the specified path in PEM format.
// If file does not exists, it will be created with 0600 mod.
func writeKey(path string, k *rsa.PrivateKey) error {
Expand Down

0 comments on commit 8f09dac

Please sign in to comment.