i am using libcurl to do HTTP request.
The request goes through authenticated proxy.
Below are my settings with regards to proxy
curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_PROXY, <proxy-server>);
curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_PROXYPORT, <port number>);
//curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
OR
curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
I cannot give user name and password for the proxy as i expect CURL to intelligently find it like how "winhttp" interface does.
I have tried both ANY and NTLM. However, at times the request goes through successfully through the proxy. At times i am getting "Authentication required: 407" during the easy perform.
Can someone tell me what i have done wrong here to see this random behavior?
Thanks for reading!!!
Related
I work in a company where we use a proxy to access any browser website.
We would like to start API testing with JMeter, but have a problem.
Whenever I try to add an API call to petstore.swagger.io/v2/pet/10, for example, and put in the proxy details in the "Advanced" section of the HTTP request + adding an HTTP authorization manager with Username + Password, it still gives me a "407 Authenticationrequired" error back.
Request headers:
Response headers:
In the information I have also it's that the proxy is "Ruleset Name: Authentication with Kerberos and NTLM Fallback".
This is quite a problem if I'd like to test internal APIs with any authorization on it.
HTTP Status code 407 means that proxy authentication required, it seems that you're using a corporate proxy to access the application under test and this proxy requires credentials.
You have 2 options of passing the proxy credentials to JMeter:
Command-line arguments like:
jmeter -H my.proxy.server -P 8000 -u username -a password
JMeter System properties (you can put these lines to system.properties file
http.proxyUser=username
http.proxyPass=password
I have an application which automatically login using my windows domain credentials. I tried with the below in Jmeter.
HTTP Request
HTTP Header manager(Authorization with Basic encoded string)
I am getting below response
Response code: 500
Response message: Internal Server Error
I was able to view content on browser. I tried the same with java code as below
CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
Authenticator.setDefault(new MyAuthenticator("username", "password"));
URL url = new URL("http://someurl");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
System.out.println(connection.getResponseCode());
System.out.println(connection.getResponseMessage());
This gives me 200 OK response.
Please let me know how to achieve this through Jmeter. Thanks in advance!
Try adding HTTP Authorization Manager in your jmeter test suite and enter your credentials there.This will likely solve your problem
Sending a request using the Test URL for Standalone Token Registration, I am faced with an internal server error with no indication as to what the problem is.
HTTP Status Code: 500:
HTTP Status Message: The request was
unsuccessful due to an unexpected condition encountered by the server.
The Test URL I'm POSTing to is:
https://test.sagepay.com/gateway/service/token.vsp
And the POST parameters are as follows:
VPSProtocol = 3.00
TxType = TOKEN
Vendor = MyVendor
VendorTxCode = UniqueVenderTxCode
Currency = GBP
NotificationURL = Publicly facing url
I can confirm that the Vendor is correct because I can successfully POST to the "Part of a Transaction Token Registration" URL, which returns a NextURL that I use to display the payment portal/entry.
I'm sending all of the required POST parameters, so I'm not sure where I've gone wrong. I hope someone can point me in the right direction.
EDIT: It was me being silly. I neglected to check the response from the HttpWebRequest (You'd think this would be my first port of call). It turns out that the vendor I'm using doesn't currently support a TxType of TOKEN. I'll have to contact SagePay support in order to get this enabled.
My push java app is behind a web proxy. I used below code to set proxy:
ProxyManager.setProxy("", "");
After executed, I got:
javapns.communication.exceptions.CommunicationException: Communication exception: java.io.IOException: Unable to tunnel through. Proxy returns "HTTP/1.1 403 Proxy Error"
Please guide me how to solve this issue.
If there is a username and password required for the proxy, then you also need to set the proxyAuthorization of the ProxyManager.
To encode the username and password, you can use the existing encodeProxyAuthorization method of the ProxyManager:
String encodeProxyAuthorization = ProxyManager.encodeProxyAuthorization(username, password);
ProxyManager.setProxyAuthorization(encodeProxyAuthorization);
I am trying to send a response to an HTTPS request, using FiddlerCore.
I need things to work like this: I put some fake URL in browser, like https://my_url_that_doesnt_exist.com/, then I intercept this request with FiddlerCore and respond to it with my data. But I only see a CONNECT and the host URL. I know this is because of HTTPS and Fiddler being a proxy. But is there a way to get the real full URL and be able to respond to HTTPS request, using FiddlerCore?
Also I use this code to create a root certificate if it's missing:
if (!Fiddler.CertMaker.rootCertExists())
{
if (!Fiddler.CertMaker.createRootCert())
{
throw new Exception("Could not create a certificate.");
}
}
also, I use these startup settings:
FiddlerCoreStartupFlags fcsf = FiddlerCoreStartupFlags.Default | FiddlerCoreStartupFlags.DecryptSSL|FiddlerCoreStartupFlags.AllowRemoteClients;
and CONFIG.IgnoreServerCertErrors = true;
This HTTPS request is not visible in Fiddler itself. I mean when I try some non-existent URL to which I'd like my app to respond with some custom content. It's also HTTP, not HTTPS, and Fiddler itself contains the following in response:
[Fiddler] DNS Lookup for "my_url_that_doesnt_exist.com" failed. The requested name is valid, but no data of the requested type was found
But if I use some existing HTTPS URL, like google plus or anything like that, I can see the HTTPS and all the request details.
So the question follows: How can I intercept HTTPS request to a non-existent URL and serve my content instead?
I can provide any additional details if needed.
Also makecert.exe is in the same folder where all my binaries are.
The problem is that HTTPS traffic flows through a CONNECT tunnel, and by default that secure traffic won't be sent if creating the CONNECT tunnel to the target server doesn't first succeed. Of course, if that target server doesn't exist, you end up with a DNS error in creating the tunnel, so the secure requests are never sent.
The workaround is to tell Fiddler to tell the client that the CONNECT tunnel was created, without even trying to contact the server. Do so by adding this inside the BeforeRequest handler:
if (oSession.HTTPMethodIs("CONNECT"))
{
oSession.oFlags["x-replywithtunnel"] = "GenerateTunnel";
return;
}