Java and Pubsubhubbub - java

I just wanted to try out the java client for pubsubhubbub from google code (https://code.google.com/p/pubsubhubbub-java/downloads/list). So I downloaded the code, signed up at SuperFeedr and tried to connect to their hub. In fact I modified the test class the is provided with the subscriber client.
sb.subscribe("http://superfeedr.com/hubbub",
"https://some.blog", hostname, null, null);
hostname is the name of the server I created by using the class Web . Server is reachable from the web.
But I all get is this exception in the GetThread class:
org.apache.http.auth.MalformedChallengeException: Authentication challenge is empty
Does anybody have a hint?
Cheers,
Andi
PS: Up to now it's quite tedious to get PuSH working, e.g. at SuperFeedr they tell you what to do (http://superfeedr.com/documentation#pubsubhubbub_implementation) but not how? I tried to implement what's necessary for push my self (HttpClient, PostMethod with parameters,etc.) but nothing works....

Related

Is it possible to force SSLHandshake to always use the hostname, not IP for HttpsUrlConnection

So I have this situation: I try to download an image from somedomain.com using HTTPS. The domain is probably misconfigured, but unfortunately I can't change that. What exactly is happening:
When I browse to https://somedomain.com/animage.jpg I get a valid certificate issued for somedomain.com, which is perfect. But when I call the same site using it's IP address, say https://123.123.123.123 - I get a (also valid) certificate for *.hostingcompany.com - the certificate of the hosting company.
Now, I try to download the contents of the file using Java's HttpsUrlConnection, nothing special:
var urlConnection = new URL(imageUrl).openConnection();
((HttpURLConnection) urlConnection).getResponseCode();
(I want to first check the response code, but it's not important here.)
This code runs inside a Spring Boot App and is run on request. It works fine for the first request since booting the app. Each subsequent request fails with java.security.cert.CertificateException: No subject alternative DNS name matching somedomain.com found. It's because on each subsequent request the SSL Handshake is sent to the IP, not hostname, and get's the hosting company's certificate.
I was trying to find different settings for the SSL classes, but to no avail. I know there is a workaround where I could supply my own HostnameVerifier which could just return true, but that won't be secure, so I don't want to do that.
Did anyone encounter such problem? Maybe I'm searching in the wrong places? Maybe it's something with DNSes? I will appreciate any help.
Turns out it is a bug in Java 11.01. It is fixed since 11.02. After switching to 11.03. the behaviour I described above is gone. Each request gets a proper certificate.
Here are the details of the bug: https://bugs.openjdk.java.net/browse/JDK-8211806

javax.net.ssl.sslhandshakeexception java.security.cert.certificateexception for soap

I am newbie in Android. I am trying to communicate .NET code using web service, but getting error in:
httpTransport.call(SOAP_ACTION, envelope);
as:
javax.net.ssl.sslhandshakeexception
java.security.cert.certificateexception
I got to know that because of certification, I am not able to use saop. Anyone help me how to resolve this?
Your screenshot shows an untrusted server-certificate (https is crossed out). Either use a (less secure) http-connection (if possible) or trust the server certificate.
The following JVM parameters might help:
Djavax.net.ssl.keyStore
Djavax.net.ssl.keyStorePassword
Djavax.net.ssl.trustStore
Djavax.net.ssl.tustStorePassword

Can't connect to server

I'm using this. I changed my base URL and database name, but when I try to sign up, I get the following error.
Any ideas? And if you can help and guide me towards what the base URL for couchDB would be great.
My current URL public static final String BASE_URL ="http://10.0.2.2:5984/_utils/database.html?colourity";
That exception basically means that you're trying to speak a protocol to the server that it doesn't handle. For example, if you're trying to connect to a SOCKS4 proxy but the server is a HTML server, it will return you that response.
Basically, I'd try to debug a bit further. See via Log.d() what are you sending to the server, what is it issuing, what it might be answering, and see why the information you're sending to them is not correct.

WebScarab : Getting a PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException while connecting via https

Hope you are doing well.I know there are many answers alike to the issue that i am going to ask but still no one seems to help.
Please help!!!
Issue:-
I am trying to connect to a secure website(HTTPS) using WebScarab, so that i can capture the traffic.Http is working fine for me.
For this i am using WebScarab as a proxy.
'client.getHostConfiguration().setProxy("127.0.0.1", 8008);'
but everytime i gets an exception (
SunCertPathBuilderException
) as stated above.
I have tried adding the website certificate to the Java using Keytool utility also.
I then added a proxy (reverse) entry in WebScarab (127.0.0.1 , 443) and changed the program to use it as a proxy server.
'client.getHostConfiguration().setProxy("127.0.0.1", 443);'
Then i got the following exception :-
org.apache.commons.httpclient.ProtocolException: The server stbeehive.oracle.com failed to respond with a valid HTTP response.
I also tried creating a .p12 certificate (for the website which i want to connect to) and importing it to WebScarab.
But inspite of all these methods i am not able to get the proper response.
I am using WebScarab as a proxy for firefox to capture its traffic and it is working fine (for both http and https).
Please help me as i have run out of ideas now :(
Are you using WebScarab or WebScarab-NG?
Please try WebScarab "classic", rather than the -NG variant. NG was a failed experiment, and no real effort was put into validating the client-side certificate functionality.
Also, what version of Java are you using, what operating system, 32 bit or 64-bit, etc, etc
Regards,
Rogan

How to read response from Https urls?

I am using following code to retrieve response code from https based urls, but when i run a prog it just hangs cont.
code:
import java.net.;
import javax.net.ssl.;
import java.io.*;
class Https2
{
public static void main(String args[]) throws Exception
{
URL u = new URL("https://myurl");
HttpsURLConnection hc = (HttpsURLConnection)u.openConnection();
hc.setConnectTimeout(3000);
hc.setReadTimeout(5000);
System.out.println("Response Code: " + hc.getResponseCode());
hc.disconnect();
}
}
How can make successfull connection to Https urls ?
any help or ideas will be well appreciated.
Thanks
Don't know if it helps but I've never had much joy with the JDK HTTP classes and have typically wound up using the Jakarta Common HTTP Client API (http://hc.apache.org/httpclient-3.x/).
I tried the attached sample with https://mail.google.com/mail/, and it worked flawlessly on linux and Mac OS X.
The authentication of the server is required by default. You need to set the javax.net.ssl.trustStore system property as the name of a keystore containing the server's certificate.
BTW, it's a good idea to catch and print the exceptions to help diagnostics.
https://mail.google.com/mail/ works on my Windows XP box. Maybe your windows firewall settings does not contain the java.exe as exception? Or the site you want to connect to uses HTTP Basic Authentication over the HTTPS connection.
Or the site needs you to identify yourself with a certificate as suggested by others?
Edit: Try your code without the timeout parameters. HTTPS connection and handshake is usually slower than a regular HTTP call. Your connection might time out due this before it can read the requested data.
I thing hc.setConnectionTimeout() might not even work because when you get to that point you already have a working connection according to the javadoc.

Categories

Resources