本文整理汇总了C#中System.Security.Cryptography.X509Certificates.X509Certificate2.GetFormattedThumbPrint方法的典型用法代码示例。如果您正苦于以下问题:C# X509Certificate2.GetFormattedThumbPrint方法的具体用法?C# X509Certificate2.GetFormattedThumbPrint怎么用?C# X509Certificate2.GetFormattedThumbPrint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Cryptography.X509Certificates.X509Certificate2
的用法示例。
在下文中一共展示了X509Certificate2.GetFormattedThumbPrint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ObjectValueForTableColumn
public NSObject ObjectValueForTableColumn (NSTableView table, NSTableColumn col, int row)
{
var value = (NSString)string.Empty;
ActionHelper.Execute (delegate() {
if (Entries != null) {
var obj = (this.Entries [row]) as CertificateDto;
X509Certificate2 cert;
switch (col.Identifier) {
case "Name":
value = (NSString)obj.Chain;
break;
case "Status":
value = (NSString)(obj.IsSigner ? "ACTIVE" : "IN-ACTIVE");
break;
case "IssuedBy":
cert = new X509Certificate2 (Encoding.ASCII.GetBytes (obj.Encoded));
value = (NSString)cert.Issuer;
break;
case "IssuedOn":
cert = new X509Certificate2 (Encoding.ASCII.GetBytes (obj.Encoded));
value = (NSString)cert.NotBefore.ToShortDateString ();
break;
case "Expiration":
cert = new X509Certificate2 (Encoding.ASCII.GetBytes (obj.Encoded));
value = (NSString)cert.NotAfter.ToShortDateString ();
break;
case "Purpose":
cert = new X509Certificate2 (Encoding.ASCII.GetBytes (obj.Encoded));
value = (NSString)cert.ToKeyUsage ();
break;
case "SubjectDn":
cert = new X509Certificate2 (Encoding.ASCII.GetBytes (obj.Encoded));
value = (NSString)cert.Subject;
break;
case "Fingerprint":
cert = new X509Certificate2 (Encoding.ASCII.GetBytes (obj.Encoded));
value = (NSString)cert.GetFormattedThumbPrint ();
break;
default:
break;
}
}
});
return value;
}
示例2: AwakeFromNib
public override void AwakeFromNib ()
{
base.AwakeFromNib ();
_certificates = new List<CertificateDto> ();
_currentStep = WizardSteps.One;
SetWizardStep ();
ReloadCertificates ();
//Events
this.BtnTestConnection.Activated += TestConnection;
this.BtnNext.Activated += OnClickNextButton;
this.BtnBack.Activated += OnClickBackButton;
this.BtnAddCertificate.Activated += (object sender, EventArgs e) => {
var openPanel = new NSOpenPanel();
openPanel.ReleasedWhenClosed = true;
openPanel.Prompt = "Select file";
var result = openPanel.RunModal();
if (result == 1)
{
var filePath = openPanel.Url.AbsoluteString.Replace("file://",string.Empty);
var cert = new X509Certificate2 ();
ActionHelper.Execute (delegate() {
cert.Import (filePath);
var certfificateDto = new CertificateDto { Encoded = cert.ToPem(), Chain = cert.GetFormattedThumbPrint()};
_certificates.Add(certfificateDto);
ReloadCertificates();
});
}
};
this.RdoIdentitySource.Activated += (object sender, EventArgs e) =>
{
SetSpnControls();
};
this.RdoDomainController.Activated += (object sender, EventArgs e) =>
{
var anyDc = RdoDomainController.SelectedTag == 1;
if(anyDc)
{
SetConnectionString();
}
else
{
TxtLdapConnection.StringValue = (NSString) string.Empty;
}
ChkProtect.Enabled = anyDc;
EnableDisableConnectionString(!anyDc);
};
this.BtnRemoveCertificate.Activated += (object sender, EventArgs e) => {
if (LstCertificates.SelectedRows.Count > 0) {
foreach (var row in LstCertificates.SelectedRows) {
_certificates.RemoveAt ((int)row);
}
ReloadCertificates();
}
};
this.BtnPrimaryImport.Activated += (object sender, EventArgs e) => {
};
this.BtnSecondaryImport.Activated += (object sender, EventArgs e) => {
};
this.TxtDomainName.Changed += (object sender, EventArgs e) => {
SetConnectionString();
};
this.ChkProtect.Activated += (object sender, EventArgs e) => {
SetConnectionString();
};
this.RdoSpn.Activated += (object sender, EventArgs e) => {
SetSpnControls();
};
BtnPrimaryImport.Enabled = false;
BtnSecondaryImport.Enabled = false;
this.TxtPrimaryUrl.Activated += (object sender, EventArgs e) =>
{
BtnPrimaryImport.Enabled = this.TxtPrimaryUrl.StringValue!= null && this.TxtPrimaryUrl.StringValue.StartsWith("ldaps://");
};
this.TxtSecondaryConnection.Activated += (object sender, EventArgs e) =>
{
BtnSecondaryImport.Enabled = this.TxtSecondaryConnection.StringValue!= null && this.TxtSecondaryConnection.StringValue.StartsWith("ldaps://");
};
BtnPrimaryImport.Activated += (object sender, EventArgs e) =>
{
ImportCertificates(TxtPrimaryUrl.StringValue);
};
BtnSecondaryImport.Activated += (object sender, EventArgs e) =>
{
ImportCertificates(TxtSecondaryConnection.StringValue);
};
if (IdentityProviderDto != null)
DtoToView ();
else
IdentityProviderDto = new IdentityProviderDto ();
this.BtnAdvanced.Activated += (object sender, EventArgs e) =>
{
var form = new ExternalDomainAdvancedSettingsController ()
{
//.........这里部分代码省略.........
示例3: ImportCertificates
void ImportCertificates(string connection)
{
try
{
var xcert = LdapSecureConnectionCertificateFetcher.FetchServerCertificate(connection);
var cert = new X509Certificate2(xcert);
var thumbprint = cert.GetFormattedThumbPrint();
var certfificateDto = new CertificateDto { Encoded = cert.ToPem(),Chain = thumbprint };
var exists = _certificates.Exists(x=>x.Chain == thumbprint);
if(exists)
{
UIErrorHelper.ShowAlert("Certificate with the same fingerprint already exists", "Error");
return;
}
_certificates.Add(certfificateDto);
ReloadCertificates ();
UIErrorHelper.ShowAlert(string.Format("Certificate with subject {0} imported successfully", cert.Subject), "Information");
}
catch (Exception exception)
{
UIErrorHelper.ShowAlert (exception.Message, "Error");
}
}