本文整理汇总了C#中Certificate类的典型用法代码示例。如果您正苦于以下问题:C# Certificate类的具体用法?C# Certificate怎么用?C# Certificate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Certificate类属于命名空间,在下文中一共展示了Certificate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: should_create_self_signed_cert
public void should_create_self_signed_cert()
{
var key = new Key(512);
var cert = new Certificate(
r =>
{
r.Dn = "cn=root.test";
r.PublicKey = key.PublicKey;
r.NotBefore = DateTime.UtcNow;
r.NotAfter = r.NotBefore.AddYears(10);
},
i =>
{
i.DistinguishedName = "cn=root.test";
i.Key = key;
});
Console.WriteLine(cert.ToString());
string pem = cert.ToPem();
Console.WriteLine(pem);
var certificate = new Certificate(pem);
Console.WriteLine(certificate.ToString());
}
开发者ID:bitdiff,项目名称:secular,代码行数:25,代码来源:CertificateTests.cs
示例2: SecureChannelException
public SecureChannelException(SecureChannelCode code, IPEndPoint peerEP, Certificate peerCertificate, string message, Exception innerException)
: base(message, innerException)
{
_code = code;
_peerEP = peerEP;
_peerCertificate = peerCertificate;
}
开发者ID:rodoviario,项目名称:BitChatClient,代码行数:7,代码来源:SecureChannelException.cs
示例3: Update
public Certificate Update(Certificate certificate)
{
Certificate cer = DbContext.Certificates.FirstOrDefault(s=>s.ID == certificate.ID);
if (cer == null)
{
cer = new Certificate();
DbContext.Certificates.Add(cer);
}
cer.DistingishedName = certificate.DistingishedName;
cer.HashAlgorithm = certificate.HashAlgorithm;
cer.PublicKeyLength = certificate.PublicKeyLength;
cer.CER = certificate.CER;
cer.LinkedGroupId = certificate.LinkedGroupId;
cer.RequestedByUser = certificate.RequestedByUser;
cer.RequestedOn = certificate.RequestedOn;
cer.UserFriendlyName = certificate.UserFriendlyName;
if (cer.LinkedGroupId == 0)
{
cer.LinkedGroupId = 1; // Default to everyone
}
DbContext.SaveChanges();
return cer;
}
开发者ID:aneillans,项目名称:MS_CertAuthority,代码行数:27,代码来源:CertificateRepository.cs
示例4: GetSignedCertificate
public static Certificate GetSignedCertificate(Uri apiUri, CertificateStore certStore)
{
using (WebClient client = new WebClient())
{
client.Headers.Add("User-Agent", GetUserAgent());
byte[] data = client.DownloadData(apiUri.AbsoluteUri + "?cmd=dlc&email=" + certStore.Certificate.IssuedTo.EmailAddress.Address);
using (BinaryReader bR = new BinaryReader(new MemoryStream(data)))
{
int errorCode = bR.ReadInt32();
if (errorCode != 0)
{
string message = Encoding.UTF8.GetString(bR.ReadBytes(bR.ReadInt32()));
string remoteStackTrace = Encoding.UTF8.GetString(bR.ReadBytes(bR.ReadInt32()));
throw new BitChatException(message);
}
Certificate cert = new Certificate(bR);
if (!cert.IssuedTo.EmailAddress.Equals(certStore.Certificate.IssuedTo.EmailAddress) || (cert.PublicKeyEncryptionAlgorithm != certStore.PrivateKey.Algorithm) || (cert.PublicKeyXML != certStore.PrivateKey.GetPublicKey()))
throw new BitChatException("Invalid signed certificate received. Please try again.");
return cert;
}
}
}
开发者ID:rodoviario,项目名称:BitChatClient,代码行数:28,代码来源:Registration.cs
示例5: BitChatNetwork
public BitChatNetwork(MailAddress peerEmailAddress, string sharedSecret, BinaryID networkID, Certificate[] knownPeerCerts, IBitChatNetworkManager networkManager, ISecureChannelSecurityManager securityManager)
{
_type = BitChatNetworkType.PrivateChat;
_peerEmailAddress = peerEmailAddress;
_sharedSecret = sharedSecret;
_networkManager = networkManager;
_securityManager = securityManager;
LoadPeers(knownPeerCerts);
if (knownPeerCerts.Length > 0)
_peerName = knownPeerCerts[0].IssuedTo.Name;
if (networkID == null)
{
//compute network id
HashAlgorithm hash = HashAlgorithm.Create("SHA1");
byte[] peerEmailAddressHash = hash.ComputeHash(Encoding.UTF8.GetBytes(_peerEmailAddress.Address.ToLower()));
byte[] selfEmailAddressHash = hash.ComputeHash(Encoding.UTF8.GetBytes(networkManager.GetLocalCredentials().Certificate.IssuedTo.EmailAddress.Address.ToLower()));
byte[] salt = new byte[20];
for (int i = 0; i < 20; i++)
{
salt[i] = (byte)(peerEmailAddressHash[i] ^ selfEmailAddressHash[i]);
}
_networkID = new BinaryID(PBKDF2.CreateHMACSHA1(_sharedSecret, salt, 200000).GetBytes(20));
}
else
{
_networkID = networkID;
}
}
开发者ID:rodoviario,项目名称:BitChatClient,代码行数:34,代码来源:BitChatNetwork.cs
示例6: BitChatService
public BitChatService(BitChatProfile profile, Certificate[] trustedRootCertificates, SecureChannelCryptoOptionFlags supportedCryptoOptions, InvalidCertificateEvent invalidCertEventHandler)
{
//verify root certs
foreach (Certificate trustedCert in trustedRootCertificates)
trustedCert.Verify(trustedRootCertificates);
//verify profile cert
profile.LocalCertificateStore.Certificate.Verify(trustedRootCertificates);
_invalidCertEventHandler = invalidCertEventHandler;
_manager = new InternalBitChatService(this, profile, trustedRootCertificates, supportedCryptoOptions);
foreach (BitChatProfile.BitChatInfo bitChatInfo in profile.BitChatInfoList)
{
if (bitChatInfo.Type == BitChatNetworkType.PrivateChat)
_bitChats.Add(_manager.CreateBitChat(new MailAddress(bitChatInfo.NetworkNameOrPeerEmailAddress), bitChatInfo.SharedSecret, bitChatInfo.NetworkID, bitChatInfo.PeerCertificateList, bitChatInfo.SharedFileList, bitChatInfo.TrackerURIs));
else
_bitChats.Add(_manager.CreateBitChat(bitChatInfo.NetworkNameOrPeerEmailAddress, bitChatInfo.SharedSecret, bitChatInfo.NetworkID, bitChatInfo.PeerCertificateList, bitChatInfo.SharedFileList, bitChatInfo.TrackerURIs));
}
//check profile cert revocation
ThreadPool.QueueUserWorkItem(CheckCertificateRevocationAsync, new Certificate[] { profile.LocalCertificateStore.Certificate });
//check trusted root cert revocation
ThreadPool.QueueUserWorkItem(CheckCertificateRevocationAsync, trustedRootCertificates);
}
开发者ID:spthaolt,项目名称:BitChatClient,代码行数:27,代码来源:BitChatService.cs
示例7: BindData
private void BindData()
{
Certificate all = new Certificate();
all.GetAllCertificates();
uiRadListViewCircularsPublic.DataSource = all.DefaultView;
uiRadListViewCircularsPublic.DataBind();
}
开发者ID:menasbeshay,项目名称:ivalley-svn,代码行数:7,代码来源:certificates.aspx.cs
示例8: UpdateCertificate
public bool UpdateCertificate(string propertyReference, string certificateReference, Certificate certificate)
{
Check.If(propertyReference).IsNotNullOrEmpty();
Check.If(certificateReference).IsNotNullOrEmpty();
Check.If(certificate).IsNotNull();
return _certificateRepository.UpdateCertificate(propertyReference, certificateReference, certificate);
}
开发者ID:letmeproperty,项目名称:Properties,代码行数:8,代码来源:CertificateService.cs
示例9: saveCertificate
public static void saveCertificate(string fileName, Certificate cert)
{
XmlSerializer s = new XmlSerializer(typeof(Certificate));
TextWriter tw = new StreamWriter(@fileName);
s.Serialize(tw, cert);
Log(m_TAG, "saving Ceritifcate");
tw.Close();
}
开发者ID:phobangers,项目名称:NetSecA1,代码行数:8,代码来源:Util.cs
示例10: ValidStartDateTest
public void ValidStartDateTest()
{
Certificate target = new Certificate();
DateTime expected = DateTime.UtcNow;
target.ValidStartDate = expected;
DateTime actual = target.ValidStartDate;
Assert.Equal(expected, actual);
}
开发者ID:JoshuaJeong,项目名称:nhin-d.net35,代码行数:9,代码来源:CertificateFacts.cs
示例11: Eksport
public Eksport()
{
this.InitializeComponent();
this.con = new Connection();
this.c = new Certificate();
this.savePath = "";
this.licensePath = "";
this.pass = "";
}
开发者ID:nicholaspaun,项目名称:Kalkulator1,代码行数:9,代码来源:Eksport.cs
示例12: CreateCertificate
public string CreateCertificate(string propertyReference, Certificate certificate)
{
Check.If(propertyReference).IsNotNullOrEmpty();
Check.If(certificate).IsNotNull();
var result = _certificateRepository.CreateCertificate(propertyReference,
certificate.CreateReference(_referenceGenerator));
return result ? certificate.CertificateReference : null;
}
开发者ID:letmeproperty,项目名称:Properties,代码行数:10,代码来源:CertificateService.cs
示例13: btnDeleteCurrentFile_Click
protected void btnDeleteCurrentFile_Click(object sender, EventArgs e)
{
Certificate objData = new Certificate();
objData = CurrentCertificate;
objData.SetColumnNull(Certificate.ColumnNames.Path);
objData.Save();
txtCurrentFile.Text = "";
txtCurrentFile.Visible = false;
btnDeleteCurrentFile.Visible = false;
lblCurrentFile.Visible = false;
}
开发者ID:menasbeshay,项目名称:ivalley-svn,代码行数:11,代码来源:certificateManagement.aspx.cs
示例14: NotifyClientCertificate
public override void NotifyClientCertificate(Certificate clientCertificate)
{
X509CertificateStructure[] chain = clientCertificate.GetCertificateList();
Console.WriteLine("DTLS server received client certificate chain of length " + chain.Length);
for (int i = 0; i != chain.Length; i++)
{
X509CertificateStructure entry = chain[i];
// TODO Create fingerprint based on certificate signature algorithm digest
Console.WriteLine(" fingerprint:SHA-256 " + TlsTestUtilities.Fingerprint(entry) + " ("
+ entry.Subject + ")");
}
}
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:12,代码来源:MockDtlsServer.cs
示例15: UpdateLoadCertificate
private static Task UpdateLoadCertificate(string resourceGroupName, string certificateName, string location, string pathToPfxFile, string certificatePassword)
{
var pfxAsBytes = File.ReadAllBytes(pathToPfxFile);
var pfxBlob = Convert.ToBase64String(pfxAsBytes);
var certificate = new Certificate
{
Location = location,
Password = certificatePassword,
PfxBlob = pfxBlob
};
return _websiteClient.Certificates.CreateOrUpdateCertificateAsync(resourceGroupName, certificateName, certificate);
}
开发者ID:suwatch,项目名称:AzureWebsitesSamples,代码行数:13,代码来源:Program.cs
示例16: CertificateMapper_DoesNotMap_CertificateId
public void CertificateMapper_DoesNotMap_CertificateId()
{
//arrange
const int id = 123;
var certificate1 = new Certificate { CertificateId = id };
var certificate2 = new Certificate { CertificateId = 0 };
//act
_certificateMapper.Map(certificate2, certificate1);
//assert
certificate1.CertificateId.Should().Be(id);
}
开发者ID:letmeproperty,项目名称:Properties,代码行数:13,代码来源:CertificateMapper_TestFixture.cs
示例17: CertificateMapper_DoesNotMap_CertificateReference
public void CertificateMapper_DoesNotMap_CertificateReference()
{
//arrange
const string reference = "ABCD1234";
var certificate1 = new Certificate { CertificateReference = reference };
var certificate2 = new Certificate { CertificateReference = string.Empty };
//act
_certificateMapper.Map(certificate2, certificate1);
//assert
certificate1.CertificateReference.Should().Be(reference);
}
开发者ID:letmeproperty,项目名称:Properties,代码行数:13,代码来源:CertificateMapper_TestFixture.cs
示例18: GroupCertificateVerification
public GroupCertificateVerification(string revocation_url, string cacert_path)
{
_revocation_url = revocation_url;
_timer = new SimpleTimer(UpdateRl, null, 0, UPDATE_PERIOD);
_timer.Start();
_revoked_users = new Hashtable();
using(FileStream fs = File.Open(cacert_path, FileMode.Open)) {
byte[] cert = new byte[fs.Length];
fs.Read(cert, 0, cert.Length);
_ca_cert = new Certificate(cert);
}
}
开发者ID:arjunprakash84,项目名称:ipop,代码行数:13,代码来源:GroupCertificateHandler.cs
示例19: CertificateMapper_Maps_CertificateDate
public void CertificateMapper_Maps_CertificateDate()
{
//arrange
var certificateDate = DateTime.UtcNow;
var certificate1 = new Certificate { ExpiryDate = DateTime.MinValue };
var certificate2 = new Certificate { ExpiryDate = certificateDate };
//act
_certificateMapper.Map(certificate2, certificate1);
//assert
certificate1.ExpiryDate.Should().Be(certificateDate);
}
开发者ID:letmeproperty,项目名称:Properties,代码行数:13,代码来源:CertificateMapper_TestFixture.cs
示例20: CertificateMapper_DoesNotMap_DateDeleted
public void CertificateMapper_DoesNotMap_DateDeleted()
{
//arrange
var dateDeleted = DateTime.Now;
var certificate1 = new Certificate { DateDeleted = dateDeleted };
var certificate2 = new Certificate { DateDeleted = DateTime.MinValue };
//act
_certificateMapper.Map(certificate2, certificate1);
//assert
certificate1.DateDeleted.Should().Be(dateDeleted);
}
开发者ID:letmeproperty,项目名称:Properties,代码行数:13,代码来源:CertificateMapper_TestFixture.cs
注:本文中的Certificate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论