Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用Mono.Security设置X509 SubjectAltName(SAN)?_C#_Google Chrome_Ssl_Mono - Fatal编程技术网

C# 如何使用Mono.Security设置X509 SubjectAltName(SAN)?

C# 如何使用Mono.Security设置X509 SubjectAltName(SAN)?,c#,google-chrome,ssl,mono,C#,Google Chrome,Ssl,Mono,Chrome 58不支持省略主题替代名称(SAN)的自签名证书。我使用Mono.Security.X509 X509CertificateBuilder()为“localhost”上的Windows OWIN服务创建证书,该服务使浏览器能够与TWAIN扫描仪通信。证书当前仅设置通用名称,因此不足以用于Chrome 58 使用Mono.Security.X509创建自签名证书以使Chrome能够与本地主机上的OWIN服务通信的正确方法是什么 RSA subjectKey = new RSA

Chrome 58不支持省略主题替代名称(SAN)的自签名证书。我使用Mono.Security.X509 X509CertificateBuilder()为“localhost”上的Windows OWIN服务创建证书,该服务使浏览器能够与TWAIN扫描仪通信。证书当前仅设置通用名称,因此不足以用于Chrome 58

使用Mono.Security.X509创建自签名证书以使Chrome能够与本地主机上的OWIN服务通信的正确方法是什么

    RSA subjectKey = new RSACryptoServiceProvider(2048);

    X509CertificateBuilder cb = new X509CertificateBuilder(3);
    cb.SerialNumber = GenerateSerialNumber();
    cb.IssuerName = "CN=localhost";
    cb.NotBefore = notBefore;
    cb.NotAfter = notAfter;
    cb.SubjectName = "CN=localhost";
    cb.SubjectPublicKey = subjectKey;
    cb.Hash = "SHA256";

    byte[] rawcert = cb.Sign(subjectKey);
    PKCS12 p12 = new PKCS12();
    p12.Password = password;

    Hashtable attributes = GetAttributes();
    p12.AddCertificate(new X509Certificate(rawcert), attributes);
    p12.AddPkcs8ShroudedKeyBag(subjectKey, attributes);

    return p12.GetBytes();
我在Jexus Manager上测试过这个


我疯狂地猜测这一添加'var san=new SubjectAltNameExtension(新字符串[0],新字符串[1]{“DNS:localhost”},新字符串[1]{“IP:127.0.0.1”},新字符串[1]{“URI:”});cb.Extensions.Add(san);'这导致错误System.FormatException:输入字符串的格式不正确。
var san = new SubjectAltNameExtension(new string[0], new string[1] { "localhost" }, new string[0], new string[0]); 
cb.Extensions.Add(san);