我们的 Dev/QA 环境使用自签名 ssl 证书,我们正在试用 Abcpdf 将 html 转换为 pdf,但呈现 html 的站点是在自签名 SSL 证书下运行的。
Doc theDoc = new Doc();
theDoc.AddImageUrl("https://mysite/Test");
theDoc.Save(@"c:\tmp\htmlimport.pdf");
theDoc.Clear();
结果是
WebSupergoo.ABCpdf9.Internal.PDFException : Unable to render HTML. Unable to access URL. COM error 800c0019. Security certificate required to access this resource is invalid.
TimeStampServiceUrl 的手册状态:
ABCpdf 使用 System.Net.WebRequest 发送时间戳请求。当您连接到 SSL/TLS 通道时,您可以使用 System.Net.ServicePointManager.ServerCertificateValidationCallback 自定义信任关系建立。
但是对于 AddImageUrl() 没有什么类似的,无论如何我都试过了,回调永远不会被击中:
public class PdfTester
{
public void Test()
{
ServicePointManager.ServerCertificateValidationCallback = ServerCertificateValidation;
Doc theDoc = new Doc();
theDoc.AddImageUrl("https://mysite/Test");
theDoc.Save(@"c:\tmp\htmlimport.pdf");
theDoc.Clear();
}
private static bool ServerCertificateValidation(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
return true;
}
}
在这种情况下如何绕过此验证的任何想法?