public KeyBundle ImportKey(string vaultName, string keyName, KeyAttributes keyAttributes, JsonWebKey webKey, bool?importToHsm) { if (string.IsNullOrEmpty(vaultName)) { throw new ArgumentNullException("vaultName"); } if (string.IsNullOrEmpty(keyName)) { throw new ArgumentNullException("keyName"); } if (keyAttributes == null) { throw new ArgumentNullException("keyAttributes"); } if (webKey == null) { throw new ArgumentNullException("webKey"); } string vaultAddress = this.vaultUriHelper.CreateVaultAddress(vaultName); Client.KeyAttributes clientAttributes = (Client.KeyAttributes)keyAttributes; webKey.KeyOps = keyAttributes.KeyOps; Client.KeyBundle clientKeyBundle = new Client.KeyBundle() { Attributes = clientAttributes, Key = webKey }; clientKeyBundle = this.keyVaultClient.ImportKeyAsync(vaultAddress, keyName, clientKeyBundle, importToHsm).GetAwaiter().GetResult(); return(new KeyBundle(clientKeyBundle, this.vaultUriHelper)); }
public KeyBundle CreateKey(string vaultName, string keyName, KeyAttributes keyAttributes) { if (string.IsNullOrEmpty(vaultName)) { throw new ArgumentNullException("vaultName"); } if (string.IsNullOrEmpty(keyName)) { throw new ArgumentNullException("keyName"); } if (keyAttributes == null) { throw new ArgumentNullException("keyAttributes"); } string vaultAddress = this.vaultUriHelper.CreateVaultAddress(vaultName); Client.KeyAttributes clientAttributes = (Client.KeyAttributes)keyAttributes; Client.KeyBundle clientKeyBundle = this.keyVaultClient.CreateKeyAsync( vaultAddress, keyName, keyAttributes.KeyType, key_ops: keyAttributes.KeyOps, keyAttributes: clientAttributes).GetAwaiter().GetResult(); return(new KeyBundle(clientKeyBundle, this.vaultUriHelper)); }
public KeyBundle SetKey(string vaultName, string keyName, KeyAttributes keyAttributes) { if (string.IsNullOrEmpty(vaultName)) { throw new ArgumentNullException("vaultName"); } if (string.IsNullOrEmpty(keyName)) { throw new ArgumentNullException("keyName"); } if (keyAttributes == null) { throw new ArgumentNullException("keyAttributes"); } Client.KeyAttributes clientAttributes = (Client.KeyAttributes)keyAttributes; string vaultAddress = this.vaultUriHelper.CreateVaultAddress(vaultName); Client.KeyBundle clientKeyBundle; try { clientKeyBundle = this.keyVaultClient.UpdateKeyAsync(vaultAddress, keyName, keyAttributes.KeyOps, attributes: clientAttributes).GetAwaiter().GetResult(); } catch (Exception ex) { throw GetInnerException(ex); } return(new KeyBundle(clientKeyBundle, this.vaultUriHelper)); }