Add root certificate to trusted store

This commit is contained in:
Diogo Monica 2015-06-18 15:13:22 -07:00
parent 71d2905066
commit d63649e54c
1 changed files with 7 additions and 2 deletions

View File

@ -35,9 +35,14 @@ func (ccs *cliCryptoService) Create(role string) (*data.PublicKey, error) {
// PEM ENcode the certificate, which will be put directly inside of TUF's root.json // PEM ENcode the certificate, which will be put directly inside of TUF's root.json
block := pem.Block{Type: "CERTIFICATE", Bytes: cert.Raw} block := pem.Block{Type: "CERTIFICATE", Bytes: cert.Raw}
pemdata := string(pem.EncodeToMemory(&block)) pemdata := pem.EncodeToMemory(&block)
return data.NewPublicKey("RSA", pemdata), nil // If this key has the role root, save it as a trusted certificate on our caStore
if role == "root" {
caStore.AddCertFromPEM(pemdata)
}
return data.NewPublicKey("RSA", string(pemdata)), nil
} }
// Sign returns the signatures for data with the given keyIDs // Sign returns the signatures for data with the given keyIDs