本文整理汇总了C#中SslPolicyErrors.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SslPolicyErrors.ToString方法的具体用法?C# SslPolicyErrors.ToString怎么用?C# SslPolicyErrors.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SslPolicyErrors
的用法示例。
在下文中一共展示了SslPolicyErrors.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnValidationCallback
public bool OnValidationCallback(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors errors)
{
if (errors.ToString() != "None")
{
MessageBox.Show("Please click yes on the next dialog box.\nThis will allow us to install the Net7 certificate.", "Certificate Install",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
try
{
X509Store Certificate = new X509Store(StoreName.Root);
X509Certificate2 cert2 = new X509Certificate2(cert);
Certificate.Open(OpenFlags.ReadWrite);
// Add Certificate
Certificate.Add(cert2);
Certificate.Close();
}
catch (Exception e)
{
MessageBox.Show("Error installing certificate: " + e.ToString());
}
}
else
{
MessageBox.Show("Certificate is installed!");
}
// Remove this message
ServicePointManager.ServerCertificateValidationCallback = null;
return true;
}
示例2: CertificateValidationCallback
private static bool CertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
bool ok = true;
if(sslPolicyErrors != SslPolicyErrors.None)
{
Console.WriteLine("SSL Certificate Validation Error!........");
Console.WriteLine(sslPolicyErrors.ToString());
ok = false;
}
return ok;
}
示例3:
private static bool ValidateServerCertificate
(Object sender, X509Certificate certificate,
X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
if (sslPolicyErrors == SslPolicyErrors.None)
return true;
else
{
//TODO:Potential for options for certificate validation!
#if DEBUG_CRYPTO
Console.Error.WriteLine(String.Format("Invalid Cert {0}: {1}",certificate.Subject,sslPolicyErrors.ToString()));
#endif
return true;
}
}
示例4: ValidateRemoteCertificate
private bool ValidateRemoteCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
if (sslPolicyErrors != SslPolicyErrors.None)
{
Console.WriteLine("SSL Certificate Validation Error!");
Console.WriteLine(sslPolicyErrors.ToString());
Console.WriteLine("Chain status:");
foreach (var s in chain.ChainStatus)
{
Console.WriteLine("\t" + s.Status + " : " + s.StatusInformation);
}
return false;
}
return true;
}
示例5: ValidateServerCertificate
public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
Debug.LogWarning ("SSL Cert Error:" + sslPolicyErrors.ToString ());
return true;
}
示例6: ValidateServerCertificate
public static bool ValidateServerCertificate (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
#if !UNITY_EDITOR
System.Console.WriteLine( "NET: SSL Cert: " + sslPolicyErrors.ToString() );
#else
Debug.LogWarning("SSL Cert Error: " + sslPolicyErrors.ToString ());
#endif
return true;
}
示例7: ValidateRemoteCertificate
/// <summary>
/// Certificate validation callback.
/// </summary>
private static bool ValidateRemoteCertificate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error)
{
// If the certificate is a valid, signed certificate, return true.
if (error == System.Net.Security.SslPolicyErrors.None)
{
return true;
}
Console.WriteLine("X509Certificate [{0}] Policy Error: '{1}'",
cert.Subject,
error.ToString());
return false;
}
示例8: ValidateServerCertificate
private static bool ValidateServerCertificate(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
if (sslPolicyErrors != SslPolicyErrors.None)
{
Debug.WriteLine("SOCKET: Certificate error: {0}", sslPolicyErrors.ToString());
return false;
}
Debug.WriteLine("SOCKET: No Certificate errors.");
return true;
}
示例9: ValidateRemoteClientCertificate
/////////////////////////////////////////////////////
// //
// ValidateRemoteClientCertificate() //
// //
/////////////////////////////////////////////////////
//Description: enforces SSL certificate validation
// rules as chosen by user.
//
//Returns: true if valid
/////////////////////////////////////////////////////
internal bool ValidateRemoteClientCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
//yay, no errors.
if (sslPolicyErrors == SslPolicyErrors.None)
return true;
WriteConnectionLog("CONNECT: Detected SSL policy errors: " + sslPolicyErrors.ToString());
//ignore name mismatch errors in certificate?
if (sslPolicyErrors == SslPolicyErrors.RemoteCertificateNameMismatch)
//if (this.IgnoreRemoteCertIgnoreNameMismatchError)
return true;
//ignore chain errors in certificate?
if (sslPolicyErrors == SslPolicyErrors.RemoteCertificateChainErrors)
//if (this.IgnoreRemoteCertIgnoreChainErrors)
return true;
//refuse communication
return false;
}
示例10: ServicePointManager_ServerCertificateValidationCallback
private bool ServicePointManager_ServerCertificateValidationCallback(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
if (sslPolicyErrors != SslPolicyErrors.None)
{
Trace.TraceWarning("Certification error found: {0}", sslPolicyErrors.ToString());
return ConfigurationAccessor.IgnoreCertificationError;
}
return true;
}
示例11: OnCertificateValidation
private static bool OnCertificateValidation(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
Console.WriteLine("Server Certificate Issued To: {0}", certificate.Subject);
Console.WriteLine("Server Certificate Issued By: {0}", certificate.Issuer);
// Return true if there are no policy errors
// The certificate can also be manually verified to
//make sure it meets your specific // policies by
// interrogating the x509Certificate object.
if (errors != SslPolicyErrors.None) {
Console.WriteLine("Server Certificate Validation Error");
Console.WriteLine(errors.ToString());
return false;
}
else {
Console.WriteLine("No Certificate Validation Errors");
return true;
}
}
示例12: ServerCertificateValidationCallback
private bool ServerCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
var msg = string.Format(CultureInfo.InvariantCulture, "Validating SSL with an ignore setting of ({0})", this.ignoreSslErrors);
this.LogMessage(msg, Severity.Informational, Verbosity.Detailed);
msg = string.Format(CultureInfo.InvariantCulture, "Current Result: ({0})", sslPolicyErrors.ToString());
this.LogMessage(msg, Severity.Informational, Verbosity.Detailed);
if (sslPolicyErrors == SslPolicyErrors.None)
{
return true;
}
return this.ignoreSslErrors;
}
示例13: ValidateServerCertificate
private bool ValidateServerCertificate(object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
Tracer.DebugFormat("ValidateServerCertificate: Issued By {0}", certificate.Issuer);
if(sslPolicyErrors == SslPolicyErrors.None)
{
return true;
}
Tracer.WarnFormat("Certificate error: {0}", sslPolicyErrors.ToString());
if(sslPolicyErrors == SslPolicyErrors.RemoteCertificateChainErrors)
{
Tracer.Error("Chain Status errors: ");
foreach( X509ChainStatus status in chain.ChainStatus )
{
Tracer.Error("*** Chain Status error: " + status.Status);
Tracer.Error("*** Chain Status information: " + status.StatusInformation);
}
}
else if(sslPolicyErrors == SslPolicyErrors.RemoteCertificateNameMismatch)
{
Tracer.Error("Mismatch between Remote Cert Name.");
}
else if(sslPolicyErrors == SslPolicyErrors.RemoteCertificateNotAvailable)
{
Tracer.Error("The Remote Certificate was not Available.");
}
// Configuration may or may not allow us to connect with an invliad broker cert.
return AcceptInvalidBrokerCert;
}
示例14: APNSCertificateException
public APNSCertificateException(SslPolicyErrors sslPolicyErrors)
: base(sslPolicyErrors.ToString())
{
this.sslPolicyErrors = sslPolicyErrors;
}
示例15: CertificateValidationCallBack
private bool CertificateValidationCallBack(object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
if (sslPolicyErrors != SslPolicyErrors.None)
{
Failure(String.Format("Certificate errors: {0}", sslPolicyErrors.ToString()), Url.AbsoluteUri);
return false;
}
DateTime expirationTime;
if (DateTime.TryParse(certificate.GetExpirationDateString(), out expirationTime))
{
TimeSpan expiringIn = expirationTime - DateTime.UtcNow;
if (expiringIn < TimeSpan.FromDays(10))
{
Degraded(String.Format("Certificate is about to expire! Expiration Date: {0}", expirationTime), Url.AbsoluteUri);
}
Success(String.Format("Certificate is ok. Expiring in {0} days.", (int)expiringIn.TotalDays), Url.AbsoluteUri);
}
else
{
Failure(String.Format("Unable to parse certificate expiration date. Expiration value: " + certificate.GetExpirationDateString()));
}
return true;
}