SSL证书由未知的证书颁发机构签名.
SSL证书包含与主机名不匹配的公用名(CN). “
但是我确实编写了接受所有证书的代码,不知道为什么还会得到错误.
我的代码:
PSCredential credential = new PSCredential("administrator",securePwd); WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("https://208.243.49.20/powershell"),"http://schemas.microsoft.com/powershell/Microsoft.Exchange",credential); connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic; Runspace runspace = System.Management.automation.Runspaces.RunspaceFactory.CreateRunspace(connectionInfo); PowerShell powershell = PowerShell.Create(); PSCommand command = new PSCommand(); command.AddCommand("New-MailBox"); command.AddParameter("name","Testname"); powershell.Commands = command; ServicePointManager.ServerCertificateValIDationCallback += new RemoteCertificateValIDationCallback( delegate { return true; }); try { runspace.open();//This is where the exception happens powershell.Runspace = runspace; Collection<PSObject> result= powershell.Invoke(); }解决方法 WSManConnectionInfo对象有两个属性可以跳过证书检查.
connectionInfo.SkipCACheck = true;connectionInfo.SkipCNCheck = true;总结
以上是内存溢出为你收集整理的c# – 如何忽略SSL证书是由未知的证书颁发机构问题签名的?全部内容,希望文章能够帮你解决c# – 如何忽略SSL证书是由未知的证书颁发机构问题签名的?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)