Files
reseed-tools/su3/reseed_certs.go
Matt Drollette 4be2dbe247 simplify su3file
2014-12-10 17:21:40 -06:00

25 lines
522 B
Go

package su3
import (
"crypto/x509"
"encoding/pem"
"io/ioutil"
"path/filepath"
"strings"
)
func signerCertificate(signer string) (*x509.Certificate, error) {
certFile := filepath.Base(signerFilename(signer))
certString, err := ioutil.ReadFile(filepath.Join("./certificates", certFile))
if nil != err {
return nil, err
}
certPem, _ := pem.Decode(certString)
return x509.ParseCertificate(certPem.Bytes)
}
func signerFilename(signer string) string {
return strings.Replace(signer, "@", "_at_", 2) + ".crt"
}