Java SSL problems

263 views
Skip to first unread message

imrank1

unread,
Oct 1, 2011, 10:06:26 PM10/1/11
to Hyperpublic API Developers
Hi :
First of all thanks for the awesome api!

Has anyone tried connecting to the api via Java? I keep getting
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
errors. I tried this from Android and from a groovy console. I know
there are ways to trust all certificates but I feel that is not the
real solution. I also get a 401 response when I try to perform a
request using curl. The same request works fine in a browser.

Thanks for the help.

Eric Tang

unread,
Oct 1, 2011, 10:57:00 PM10/1/11
to hyperpublic-a...@googlegroups.com, Hyperpublic API Developers
Hmm... There is no java wrapper at this point, but I have seen similar issues in other environments. You can usually turn off verification, the details depend on the library you are using. It might be a good option for the purpose of this hackathon.

Eric

Eric Tang

unread,
Oct 1, 2011, 10:58:44 PM10/1/11
to hyperpublic-a...@googlegroups.com, Hyperpublic API Developers
Btw, for the 401 error on curl, if you can paste your command, I'll have a better idea of how to solve it.

Eric

On Oct 1, 2011, at 10:06 PM, imrank1 <imr...@gmail.com> wrote:

Doug Petkanics

unread,
Oct 1, 2011, 11:06:56 PM10/1/11
to hyperpublic-a...@googlegroups.com
Hmmm, we'll definitely look into this, but in the short term I would suggest using the setting to ignore SSL warnings.

I'll report back when we get this figured out.

On Oct 1, 2011, at 10:06 PM, imrank1 <imr...@gmail.com> wrote:

imrank1

unread,
Oct 1, 2011, 11:12:03 PM10/1/11
to Hyperpublic API Developers
Here's the curl command I'm using : ( I took out my client and secret
values )

curl -v
https://api.hyperpublic.com/api/v1/offers?lat=40.74&lon=-74.01&q=mixology&status=all&client_id=L<CLIENT_KEY>&client_secret=<CLIENT_SECRET>



I get the following response :

* Trying 184.72.235.27... connected
* Connected to api.hyperpublic.com (184.72.235.27) port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using DHE-RSA-AES256-SHA
* Server certificate:
* subject: O=api.hyperpublic.com; OU=Domain Control Validated;
CN=api.hyperpublic.com
* start date: 2011-03-18 19:05:12 GMT
* expire date: 2012-03-18 19:05:12 GMT
* subjectAltName: api.hyperpublic.com matched
* issuer: C=US; ST=Arizona; L=Scottsdale; O=GoDaddy.com, Inc.;
OU=http://certificates.godaddy.com/repository; CN=Go Daddy Secure
Certification Authority; serialNumber=07969287
* SSL certificate verify ok.
> GET /api/v1/offers?lat=40.74 HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
> Host: api.hyperpublic.com
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Server: nginx/0.7.67
< Date: Sun, 02 Oct 2011 03:10:39 GMT
< Content-Type: text/html; charset=utf-8
< Connection: keep-alive
< X-Ua-Compatible: IE=Edge,chrome=1
< X-Runtime: 0.007649
< Cache-Control: no-cache
< Content-Length: 21
< X-Varnish: 1274196043
< Age: 0
< Via: 1.1 varnish
<
* Connection #0 to host api.hyperpublic.com left intact


Thanks
Imran
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
Invalid OAuth Request
On Oct 1, 10:58 pm, Eric Tang <et...@hyperpublic.com> wrote:
> Btw, for the 401 error on curl, if you can paste your command, I'll have a better idea of how to solve it.
>
> Eric
>

Eric Tang

unread,
Oct 1, 2011, 11:23:12 PM10/1/11
to hyperpublic-a...@googlegroups.com, Hyperpublic API Developers
Hmm... Can you try to query another endpoint with the same set of credentials and see if you still get a 401 error? I just tried to query using another set of credentials and was able to get results.

Eric

imrank1

unread,
Oct 1, 2011, 11:30:49 PM10/1/11
to Hyperpublic API Developers
Ya, interestingly if I just take the sample request you have on the
Places page without changing the client and secret and use curl
(
https://api.hyperpublic.com/api/v1/places?lat=40.7&lon=-74.00&limit=2&client_id=8UufhI6bCKQXKMBn7AUWO67Yq6C8RkfD0BGouTke&client_secret=zdoROY5XRN0clIWsEJyKzHedSK4irYee8jpnOXaP
)

I also get a Invalid Oauth Request ( 401 )

I also get that with my own credentials.

On Oct 1, 11:23 pm, Eric Tang <et...@hyperpublic.com> wrote:
> Hmm... Can you try to query another endpoint with the same set of credentials and see if you still get a 401 error?  I just tried to query using another set of credentials and was able to get results.
>
> Eric
>
> On Oct 1, 2011, at 11:12 PM, imrank1 <imra...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Here's the curl command I'm using : ( I took out my client and secret
> > values )
>
> > curl -v
> >https://api.hyperpublic.com/api/v1/offers?lat=40.74&lon=-74.01&q=mixo...<CLIENT_KEY>&client_secret=<CLIENT_SECRET>

Eric Tang

unread,
Oct 1, 2011, 11:46:33 PM10/1/11
to hyperpublic-a...@googlegroups.com, Hyperpublic API Developers
Are you able to get a response in a browser? You should be able to click on the link on the documentation site and get json responses in your browser.

Eric

imrank1

unread,
Oct 1, 2011, 11:49:59 PM10/1/11
to Hyperpublic API Developers
Yes, when I click the link for the request in the browser it works
fine and I get a json response. Also, if I change that request and
replace the client and secret values with my own it works fine.

On Oct 1, 11:23 pm, Eric Tang <et...@hyperpublic.com> wrote:
> Hmm... Can you try to query another endpoint with the same set of credentials and see if you still get a 401 error?  I just tried to query using another set of credentials and was able to get results.
>
> Eric
>
> On Oct 1, 2011, at 11:12 PM, imrank1 <imra...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Here's the curl command I'm using : ( I took out my client and secret
> > values )
>
> > curl -v
> >https://api.hyperpublic.com/api/v1/offers?lat=40.74&lon=-74.01&q=mixo...<CLIENT_KEY>&client_secret=<CLIENT_SECRET>

Parminder Singh

unread,
Oct 2, 2011, 8:33:09 AM10/2/11
to hyperpublic-a...@googlegroups.com

I'm working on a java wrapper.

We get that ssl exception because of the server cert. For now I've written a workaround that basically ignores the error and goes ahead with the handshake.

Imran Khawaja

unread,
Oct 2, 2011, 10:59:08 AM10/2/11
to hyperpublic-a...@googlegroups.com

Any idea when that wrapper will be available? In the meantume what did you do to ignore the cert? I tried to add it to my truststore but thay didn't work.

Thanks

Parminder Singh

unread,
Oct 2, 2011, 2:10:40 PM10/2/11
to hyperpublic-a...@googlegroups.com
Most likely next 3-4 weeks. 

Here's the solution I tried: http://stackoverflow.com/questions/1828775/httpclient-and-ssl

N. Peeters

unread,
Oct 7, 2011, 3:08:38 AM10/7/11
to Hyperpublic API Developers
I wrote a Java client that handles this error (not sure it's the most
graceful but it works). Anyone interested?

Nicolas

On Oct 2, 8:10 pm, Parminder Singh <parminde...@gmail.com> wrote:
> Most likely next 3-4 weeks.
>
> Here's the solution I tried:http://stackoverflow.com/questions/1828775/httpclient-and-ssl
>
>
>
>
>
>
>
> On Sun, Oct 2, 2011 at 10:59 AM, Imran Khawaja <imra...@gmail.com> wrote:
> > Any idea when that wrapper will be available? In the meantume what did you
> > do to ignore the cert? I tried to add it to my truststore but thay didn't
> > work.
>
> > Thanks
> > On Oct 2, 2011 8:33 AM, "Parminder Singh" <parminde...@gmail.com> wrote:
> > > I'm working on a java wrapper.
>
> > > We get that ssl exception because of the server cert. For now I've
> > written a
> > > workaround that basically ignores the error and goes ahead with the
> > > handshake.
> > > On Oct 1, 2011 10:58 PM, "Eric Tang" <et...@hyperpublic.com> wrote:
>
> > >> Btw, for the 401 error on curl, if you can paste your command, I'll have
> > a
> > >> better idea of how to solve it.
>
> > >> Eric
>

N. Peeters

unread,
Oct 7, 2011, 3:09:11 AM10/7/11
to Hyperpublic API Developers
Like I said in a reply, I wrote a Java client that works. Interested?

On Oct 2, 4:59 pm, Imran Khawaja <imra...@gmail.com> wrote:
> Any idea when that wrapper will be available? In the meantume what did you
> do to ignore the cert? I tried to add it to my truststore but thay didn't
> work.
>
> Thanks
> On Oct 2, 2011 8:33 AM, "Parminder Singh" <parminde...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I'm working on a java wrapper.
>
> > We get that ssl exception because of the server cert. For now I've written
> a
> > workaround that basically ignores the error and goes ahead with the
> > handshake.
> > On Oct 1, 2011 10:58 PM, "Eric Tang" <et...@hyperpublic.com> wrote:
>
> >> Btw, for the 401 error on curl, if you can paste your command, I'll have
> a
> >> better idea of how to solve it.
>
> >> Eric
>

Imran Khawaja

unread,
Oct 7, 2011, 7:48:19 AM10/7/11
to hyperpublic-a...@googlegroups.com
Ya, I'd be interested. Can you post somewhere on github?

Thanks
imran

--
Imran

N. Peeters

unread,
Oct 7, 2011, 11:59:04 AM10/7/11
to Hyperpublic API Developers
Hi there,
I created a Java API wrapper. Maybe useful for some of your users.
It's still a bit rough but it should get most people started.
https://github.com/peetersn/Java-hyperpublic-api-wrapper
Have fun.
Cheers,
Nicolas

N. Peeters

unread,
Oct 20, 2011, 8:52:19 AM10/20/11
to hyperpublic-a...@googlegroups.com
In case anybody's interested, I did some improvements in the client code (changed code with 264 additions and 643 deletions) (less code is always better isn't it!)
Reply all
Reply to author
Forward
0 new messages