Example #1
0
// SKI returns the subject key identifier of this key.
func (k *rsaPublicKey) SKI() (ski []byte) {
	raw, _ := utils.PublicKeyToPEM(k.pubKey, nil)
	// TODO: Error should not be thrown. Anyway, move the marshalling at initialization.

	hash := sha256.New()
	hash.Write(raw)
	return hash.Sum(nil)
}
Example #2
0
func (ks *FileBasedKeyStore) storePublicKey(alias string, publicKey interface{}) error {
	rawKey, err := utils.PublicKeyToPEM(publicKey, ks.pwd)
	if err != nil {
		logger.Errorf("Failed converting public key to PEM [%s]: [%s]", alias, err)
		return err
	}

	err = ioutil.WriteFile(ks.getPathForAlias(alias, "pk"), rawKey, 0700)
	if err != nil {
		logger.Errorf("Failed storing private key [%s]: [%s]", alias, err)
		return err
	}

	return nil
}