Screen Scraping HTTPS

M

Michael C#

Hi all,

I'm writing a web service that uses HttpWebRequest/HttpWebResponse to screen
scrape. It works fine for regular HTTP sites, but for an HTTPS site (no
username/password) it gets stuck... I think the certificate is causing it
to fail. Here's the error message I get: "The underlying connection was
closed: Could not establish trust relationship with remote server." Any
ideas? Thanks
 
J

Jon Maz

Can you post your solution? That way you'll help anyone else who has the
same issue.
 
M

Michael C#

Yeah sure. The problem was that the site name and certificate name didn't
match. It's a government site so they were using the certificate of their
'parent department'. This was causing the Certificate Validation to fail.
To get around it, I created a Class that implements the ICertificatePolicy
interface. In the CheckValidationResult public function of the Class, I
returned True. Finally I assigned an instance of the Class to the
ServicePointManager.CertificatePolicy property.

One word of caution: this pretty much beats any security via certificates
completely into the ground. To get some level of security back, you can
code the CheckValidationResult function to check values of the Certificate
when it's passed in, like certificate.GetName(), GetEffectiveDateString(),
GetExpirationDateString(), etc.
 
J

J. Michael Terenin

Michael,
Could you revisit this thread discussion and perhaps show an example of your
code ? I am attempting the same thing, using Fiddler as a debugger, and am
noticing a similar breakdown when I try an access a web page over SSL (https)
.. I actually found your solution on another blog site, but it still didn't
help me resolve my block.

Much thanks !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top