1

我们的 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;
    }
}

在这种情况下如何绕过此验证的任何想法?

4

1 回答 1

1

尝试通过 fiddler 运行它,您可能会遇到由http://support.microsoft.com/kb/2677070引起的此问题

此问题的症状导致您将注意力集中在目标 URL 上,但可能有几个对该知识库文章中列出的 Windows 更新 URL 的子请求以及对证书中 URL 的请求。我们遇到了这个问题,fiddler 能够暴露 502 错误,导致 800C0019 错误。

我们通过将 fiddler 公开的所有 URL 添加到客户的例外列表来修复它,但这里有来自 Microsoft 的修复

当然,这只是一个可能的解决方案。

于 2014-05-22T10:53:09.723 回答