private static VerifyCertificateResponse HandleCertError(VerifyCertificateParameters errorParams) { PrintCertificateAndErrorDetails(errorParams); // Return Valid to ignore certificate error. return(VerifyCertificateResponse.Valid()); }
private static VerifyCertificateResponse HandleCertError(VerifyCertificateParameters errorParams) { Certificate certificate = errorParams.Certificate; foreach (CertificateVerificationStatus status in errorParams.VerifyStatuses) { Console.WriteLine("CertificateVerificationStatus = " + status); } Console.WriteLine("SerialNumber = " + certificate.SerialNumber); Console.WriteLine("FingerPrint = " + certificate.Fingerprint); Console.WriteLine("CAFingerPrint = " + certificate.CaFingerPrint); string subject = certificate.Subject; Console.WriteLine("Subject = " + subject); string issuer = certificate.Issuer; Console.WriteLine("Issuer = " + issuer); Console.WriteLine("KeyUsages = " + string.Join(", ", certificate.KeyUsages)); Console.WriteLine("ExtendedKeyUsages = " + string.Join(", ", certificate.ExtendedKeyUsages)); Console.WriteLine("Expired = " + certificate.Expired); // Return Valid to ignore certificate error. return(VerifyCertificateResponse.Valid()); }
private static VerifyCertificateResponse VerifyCert(VerifyCertificateParameters parameters) { // Reject SSL certificate for all "google.com" hosts. if (parameters.HostName.Contains("google.com")) { Console.WriteLine("Rejected certificate for " + parameters.HostName); return(VerifyCertificateResponse.Invalid()); } return(VerifyCertificateResponse.Default()); }
private static void PrintCertificateAndErrorDetails(VerifyCertificateParameters errorParams) { foreach (CertificateVerificationStatus status in errorParams.VerifyStatuses) { Console.WriteLine($"CertificateVerificationStatus = {status}"); } Certificate certificate = errorParams.Certificate; Console.WriteLine($"SerialNumber = {certificate.SerialNumber}"); Console.WriteLine($"FingerPrint = {certificate.Fingerprint}"); Console.WriteLine($"CAFingerPrint = {certificate.CaFingerPrint}"); Console.WriteLine($"Subject = {certificate.Subject}"); Console.WriteLine($"Issuer = {certificate.Issuer}"); Console.WriteLine($"KeyUsages = {string.Join(", ", certificate.KeyUsages)}"); Console.WriteLine($"ExtendedKeyUsages = {string.Join(", ", certificate.ExtendedKeyUsages)}"); Console.WriteLine($"Expired = {certificate.Expired}"); }