Bumping an old post - https web request [modified]
-
The only dodgy bit I can see is the proxy. Can you try connecting directly? If your proxy is not forwarding your credentials correctly, you will get a 401. I forget how, but there is a way to add your username and password to the URI. It's something like https://username:password@www.... Might be worth a try. Nick
---------------------------------- Be excellent to each other :)
Thanks for the reply Nick. Tried removing the Proxy but I don't get off the network if I do. Maybe embedding the credentials in the URI will work. I'll give that a go and let you know how I make out.
Mike Devenney
-
Thanks for the reply Nick. Tried removing the Proxy but I don't get off the network if I do. Maybe embedding the credentials in the URI will work. I'll give that a go and let you know how I make out.
Mike Devenney
You'll have to find a computer that isn't behind your proxy. Do you run a DMZ? Or a web server? You can always try from someone's home. I just googled the URI encoding and I got it right :-D http://en.wikipedia.org/wiki/URI_scheme[^] Please let us know how you get on. Nick
---------------------------------- Be excellent to each other :)
-
You'll have to find a computer that isn't behind your proxy. Do you run a DMZ? Or a web server? You can always try from someone's home. I just googled the URI encoding and I got it right :-D http://en.wikipedia.org/wiki/URI_scheme[^] Please let us know how you get on. Nick
---------------------------------- Be excellent to each other :)
And the games continue. My username for the SWIFT site is my password, which includes the @ sign. I got an error back saying that
a port # is expected because a colon was found in the request.
I assume this is happening because of the @ in my username. Would I escape the @ character?
Mike Devenney
-
And the games continue. My username for the SWIFT site is my password, which includes the @ sign. I got an error back saying that
a port # is expected because a colon was found in the request.
I assume this is happening because of the @ in my username. Would I escape the @ character?
Mike Devenney
Not sure about that. Have you tried putting the uri in a web browser? Nick
---------------------------------- Be excellent to each other :)
-
Not sure about that. Have you tried putting the uri in a web browser? Nick
---------------------------------- Be excellent to each other :)
Before I was getting an error about having a colon in the request with no port specified. Now, I get this error from IE in a dialog box entitled Address Bar. Windows cannot find 'https://mdevenney@wilmingtontrust.com:Password@www2.swift.com/bicdownload/bicdownloader?action=getfile&productline=bicdir&product=bicdb&content=full&format=txt&platform=win'. Check spelling and try again. :mad:
Mike Devenney
-
Before I was getting an error about having a colon in the request with no port specified. Now, I get this error from IE in a dialog box entitled Address Bar. Windows cannot find 'https://mdevenney@wilmingtontrust.com:Password@www2.swift.com/bicdownload/bicdownloader?action=getfile&productline=bicdir&product=bicdb&content=full&format=txt&platform=win'. Check spelling and try again. :mad:
Mike Devenney
I don't know how to escape an @ in your username. I just tried putting the uri without username:password into ie8 and a dialog popped up asking for credentials. Could you try this, enter your credentials and see if you get the file? If you do, it means your account and local network are working, which would narrow the problem down to the credentials your proxy is passing when you use WebRequest. Nick
---------------------------------- Be excellent to each other :)
-
I don't know how to escape an @ in your username. I just tried putting the uri without username:password into ie8 and a dialog popped up asking for credentials. Could you try this, enter your credentials and see if you get the file? If you do, it means your account and local network are working, which would narrow the problem down to the credentials your proxy is passing when you use WebRequest. Nick
---------------------------------- Be excellent to each other :)
I'm able to get the file using the URI and entering the credentials into the dialog that pops up. Is there any way to see what the proxy is passing?
Mike Devenney
-
I'm able to get the file using the URI and entering the credentials into the dialog that pops up. Is there any way to see what the proxy is passing?
Mike Devenney
You could try setting
myReq.PreAuthenticate = true;
Might work... Nick---------------------------------- Be excellent to each other :)
-
You could try setting
myReq.PreAuthenticate = true;
Might work... Nick---------------------------------- Be excellent to each other :)
Sounds like your idea of the proxy server interfering is a winner. I'm talking over my head here but I'll do my best to explain what I just learned. I spoke with two of our architects who said that any https requests have to spoof a validated certificate because our infosec dept strips out the remote host's certificate and inserts one of their own. I have some sample code that one of them uses for a web service that makes https requests. Because it's a web service the code is slightly different but it's the same idea...
ServicePointManager.ServerCertificateValidationCallback
+= new RemoteCertificateValidationCallback(ValidateRemoteCertificate)private static bool ValidateRemoteCertificate
(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors policyErrors)
{
return true;
}By "faking" the true value for the ValidateRemoteCertificate method the authentication succeeds and the connection will open successfully. I'm off to work this into my routine. If/when I get it working I'll post the "correct" code. Thanks for helping me work through this! :thumbsup:
Mike Devenney
-
Sounds like your idea of the proxy server interfering is a winner. I'm talking over my head here but I'll do my best to explain what I just learned. I spoke with two of our architects who said that any https requests have to spoof a validated certificate because our infosec dept strips out the remote host's certificate and inserts one of their own. I have some sample code that one of them uses for a web service that makes https requests. Because it's a web service the code is slightly different but it's the same idea...
ServicePointManager.ServerCertificateValidationCallback
+= new RemoteCertificateValidationCallback(ValidateRemoteCertificate)private static bool ValidateRemoteCertificate
(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors policyErrors)
{
return true;
}By "faking" the true value for the ValidateRemoteCertificate method the authentication succeeds and the connection will open successfully. I'm off to work this into my routine. If/when I get it working I'll post the "correct" code. Thanks for helping me work through this! :thumbsup:
Mike Devenney
GAH :confused: Thought that the certificate was going to be the silver bullet but I still get my now least favorite response: The server returned an error: (401) Unauthorized. I'm headed back to the drawing board. Not defeated yet, but getting there. X|
Mike Devenney