本文整理汇总了C#中System.Security.Cryptography.X509Certificates.X509Certificate2.MatchEmailNameOrName方法的典型用法代码示例。如果您正苦于以下问题:C# X509Certificate2.MatchEmailNameOrName方法的具体用法?C# X509Certificate2.MatchEmailNameOrName怎么用?C# X509Certificate2.MatchEmailNameOrName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Cryptography.X509Certificates.X509Certificate2
的用法示例。
在下文中一共展示了X509Certificate2.MatchEmailNameOrName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestNameExtraction
public void TestNameExtraction(X509Certificate2 cert)
{
string name = cert.ExtractEmailNameOrName();
Assert.False(string.IsNullOrEmpty(name));
Assert.True(cert.MatchEmailNameOrName(name));
}
示例2: TestVerifySignature_dNSName_in_subjectAltName_doesNotMatch_Health_Internet_Domain
public void TestVerifySignature_dNSName_in_subjectAltName_doesNotMatch_Health_Internet_Domain()
{
string signingCert = @"MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIAwggQhMIID
iqADAgECAghs4QKo+HXxyzANBgkqhkiG9w0BAQUFADCBpDEkMCIGCSqGSIb3DQEJARYVdHJhbnNw
b3J0LXRlc3Rpbmcub3JnMR4wHAYDVQQDDBV0cmFuc3BvcnQtdGVzdGluZy5vcmcxCzAJBgNVBAYT
AlVTMQswCQYDVQQIDAJNRDEVMBMGA1UEBwwMR2FpdGhlcnNidXJnMSswKQYDVQQKDCJ0cmFuc3Bv
cnQtdGVzdGluZy5vcmcgVHJ1c3QgQW5jaG9yMB4XDTEzMDMwMTIwMDQxOFoXDTIzMDIyMzIwMDQx
OFowga4xKDAmBgkqhkiG9w0BCQEWGWZvby50cmFuc3BvcnQtdGVzdGluZy5vcmcxIjAgBgNVBAMM
GXR0dC50cmFuc3BvcnQtdGVzdGluZy5vcmcxCzAJB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9ydC10ZXN0aW5nLm9yZzEeMBwGA1UEAwwVdHJhbnNwb3J0LXRlc3Rpbmcu
b3JnMQswCQYDVQQGEwJVUzELMAkGA1UECAwCTUQxFTATBgNVBAcMDEdhaXRoZXJzYnVyZzErMCkG
A1UECgwidHJhbnNwb3J0LXRlc3Rpbmcub3JnIFRydXN0IEFuY2hvcgIIbOECqPh18cswCQYFKw4D
AhoFAKCCAXUwGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTMwNTIz
MTkwODI0WjAjBgkqhkiG9w0BCQQxFgQUsKPMV4E62N7WgadDDEyKEiBKHDswTwYJKoZIhvcNAQkP
MUIwQDAKBggqhkiG9w0DBzAOBggqhkiG9w0DAgICAIAwBwYFKw4DAgcwCwYJKoZIhvcNAQcBMAwG
CiqGSIb3DQEJFgEwgcQGCyqGSIb3DQEJEAILMYG0oIGxMIGkMSQwIgYJKoZIhvcNAQkBFhV0cmFu
c3BvcnQtdGVzdGluZy5vcmcxHjAcBgNVBAMMFXRyYW5zcG9ydC10ZXN0aW5nLm9yZzELMAkGA1UE
BhMCVVMxCzAJBgNVBAgMAk1EMRUwEwYDVQQHDAxHYWl0aGVyc2J1cmcxKzApBgNVBAoMInRyYW5z
cG9ydC10ZXN0aW5nLm9yZyBUcnVzdCBBbmNob3ICCGzhAqj4dfHLMA0GCSqGSIb3DQEBAQUABIGA
g9DY8Y/ubZz99nUCA0ZEMUYEaLG+gWjzD0TXU+IBKmzX55p2DktPBSGz+rO3TdDzCa3oRJsHBIFp
4jyAfk0shWgFxuio9fpIBvJNOvhSmjE6e3T+is5TE3ZGnhkMCic1ukOxZd9kTZnot3JMHhOlpgnt
8RhS81VCdshLgSTuLLwAAAAAAAA=";
X509Certificate2 cert = new X509Certificate2();
cert.Import(Encoding.UTF8.GetBytes(signingCert));
Assert.Equal("foo.transport-testing.org", cert.GetNameInfo(X509NameType.DnsFromAlternativeName, false));
Assert.False(cert.MatchEmailNameOrName("[email protected]"));
Assert.False(cert.MatchDnsOrEmailOrName("ttt.transport-testing.org"));
}