本文整理汇总了C#中System.Security.SecureString.ConvertToString方法的典型用法代码示例。如果您正苦于以下问题:C# SecureString.ConvertToString方法的具体用法?C# SecureString.ConvertToString怎么用?C# SecureString.ConvertToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.SecureString
的用法示例。
在下文中一共展示了SecureString.ConvertToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetSecret
public Secret SetSecret(string vaultName, string secretName, SecureString secretValue, SecretAttributes secretAttributes)
{
if (string.IsNullOrEmpty(vaultName))
throw new ArgumentNullException("vaultName");
if (string.IsNullOrEmpty(secretName))
throw new ArgumentNullException("secretName");
if (secretValue == null)
throw new ArgumentNullException("secretValue");
if (secretAttributes == null)
throw new ArgumentNullException("secretAttributes");
string value = secretValue.ConvertToString();
string vaultAddress = this.vaultUriHelper.CreateVaultAddress(vaultName);
var attributes = (Azure.KeyVault.Models.SecretAttributes)secretAttributes;
Azure.KeyVault.Models.SecretBundle secret;
try
{
secret = this.keyVaultClient.SetSecretAsync(vaultAddress, secretName, value,
secretAttributes.TagsDictionary, secretAttributes.ContentType, attributes).GetAwaiter().GetResult();
}
catch (Exception ex)
{
throw GetInnerException(ex);
}
return new Secret(secret, this.vaultUriHelper);
}
示例2: SetCertificateIssuer
public IssuerBundle SetCertificateIssuer(
string vaultName,
string issuerName,
string issuerProvider,
string accountId,
SecureString apiKey,
KeyVaultCertificateOrganizationDetails organizationDetails)
{
if (string.IsNullOrEmpty(vaultName))
throw new ArgumentNullException("vaultName");
if (string.IsNullOrEmpty(issuerName))
throw new ArgumentNullException("issuerName");
if (string.IsNullOrEmpty(issuerProvider))
throw new ArgumentNullException("issuerProvider");
string vaultAddress = this.vaultUriHelper.CreateVaultAddress(vaultName);
var issuer = new IssuerBundle
{
Provider = issuerProvider,
OrganizationDetails = organizationDetails == null ? null : organizationDetails.ToOrganizationDetails(),
};
if (!string.IsNullOrEmpty(accountId) || apiKey != null)
{
issuer.Credentials = new IssuerCredentials
{
AccountId = accountId,
Password = apiKey == null ? null : apiKey.ConvertToString(),
};
}
IssuerBundle resultantIssuer;
try
{
resultantIssuer = this.keyVaultClient.SetCertificateIssuerAsync(
vaultAddress,
issuerName,
issuer.Provider,
issuer.Credentials,
issuer.OrganizationDetails,
issuer.Attributes).GetAwaiter().GetResult();
}
catch (Exception ex)
{
throw GetInnerException(ex);
}
return resultantIssuer;
}
示例3: ImportCertificate
public CertificateBundle ImportCertificate(string vaultName, string certName, string base64CertColl, SecureString certPassword, IDictionary<string, string> tags)
{
if (string.IsNullOrEmpty(vaultName))
throw new ArgumentNullException("vaultName");
if (string.IsNullOrEmpty(certName))
throw new ArgumentNullException("certName");
if (string.IsNullOrEmpty(base64CertColl))
throw new ArgumentNullException("base64CertColl");
CertificateBundle certBundle;
string vaultAddress = this.vaultUriHelper.CreateVaultAddress(vaultName);
var password = (certPassword == null) ? string.Empty : certPassword.ConvertToString();
try
{
certBundle = this.keyVaultClient.ImportCertificateAsync(vaultAddress, certName, base64CertColl, password, new CertificatePolicy
{
SecretProperties = new SecretProperties
{
ContentType = "application/x-pkcs12"
}
}, null, tags).GetAwaiter().GetResult();
}
catch (Exception ex)
{
throw GetInnerException(ex);
}
return certBundle;
}