本文整理汇总了C#中Certificate.SelfSign方法的典型用法代码示例。如果您正苦于以下问题:C# Certificate.SelfSign方法的具体用法?C# Certificate.SelfSign怎么用?C# Certificate.SelfSign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Certificate
的用法示例。
在下文中一共展示了Certificate.SelfSign方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterAsync
private void RegisterAsync(CertificateProfile profile)
{
try
{
//register
AsymmetricCryptoKey privateKey;
if (rbImportRSA.Checked)
privateKey = AsymmetricCryptoKey.CreateUsing(_parameters);
else
privateKey = new AsymmetricCryptoKey(AsymmetricEncryptionAlgorithm.RSA, 4096);
Certificate selfSignedCert = new Certificate(CertificateType.RootCA, "", profile, CertificateCapability.SignCACertificate, DateTime.UtcNow, DateTime.UtcNow, AsymmetricEncryptionAlgorithm.RSA, privateKey.GetPublicKey());
selfSignedCert.SelfSign("SHA256", privateKey, null);
Registration.Register(Program.SIGNUP_URI, selfSignedCert);
if (_profile == null)
_profile = new BitChatProfile(null, new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0), GetDownloadsPath(), BitChatProfile.DefaultTrackerURIs);
_profile.LocalCertificateStore = new CertificateStore(selfSignedCert, privateKey);
_profile.SetPassword(SymmetricEncryptionAlgorithm.Rijndael, 256, txtProfilePassword.Text);
_profileFilePath = Path.Combine(_localAppData, _profile.LocalCertificateStore.Certificate.IssuedTo.Name + ".profile");
using (FileStream fS = new FileStream(_profileFilePath, FileMode.Create, FileAccess.ReadWrite))
{
_profile.WriteTo(fS);
}
this.Invoke(new Action<object>(RegistrationSuccess), new object[] { null });
}
catch (Exception ex)
{
this.Invoke(new Action<object>(RegistrationFail), new object[] { ex.Message });
}
}