Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Reading from HTTPS in Java


clansfear's Avatar
Member
0 0

Hello, I've been coding in java for quite some time now, but for the first time I need to connect to a https . I know there is HttpsUrlConnection class and I've used it but I'm getting SSLHandshakeException no matter what I do with it. Now I've never done it before so it isn't intuitive for me but I guess i'm missing certification. I don't really know how to go about it, the Internet is saying about keychains but it doesn't really make sense to me, do you know any resource that could explain me what and why I should do?


CapnDelete's Avatar
Member
0 3

I've found that when I'm having an issue with the code, it's generally because I don't understand the basics of what I'm trying to implement. I would google SSL or youtube if you're more of a visual learner. I think once you understand how SSL works, suddenly those problems are solved. Don't focus on Java SSL, focus on SSL in general.


clansfear's Avatar
Member
0 0

I saved the certificate with chrome and added it to my keystore with keytool and I still get the error. Then I tried to disable the security altogether but I didn't even understand what I'm doing and it still gave me the exception … I'm sure that's some basic oversight of mine, it can't be that hard to connect to https.

EDIT: As you posted right when I did - I'll read on SSL. I'm still worried that I will have difficulties implementing it in Java tho.


clansfear's Avatar
Member
0 0

Thanks for all your help guys, I managed to read dozens of https sites and now I actually know how does it work. There is still a thing that boggles my mind - it doesn't work with hellboundhackers. I still get the same good ol' exception with failed handshake. Why doesn't this page want to welcome my app? :(


rex_mundi's Avatar
☆ Lucifer ☆
3,110 12

There are plenty of java coders on the site, someone will post the answer sooner or later.


FikretPhh's Avatar
Member
1,260 0

From the top of my head:

  • check if u added the certificate to java trust store "cacerts", should be in jre/lib/security folder, also check if you have the right jdk on the OS path.

You can try running the program with -Djavax.net.ssl.trustStore="path/to/trust/store"

Don't forget the "" when adding the path, if you are using windows, and have spaces in your path, it's not gonna find it.

You can PM me freely.


clansfear's Avatar
Member
0 0

I tried all the methods and sent you a PM, as it still doesn't work -.- If there is anyone else with some bright idea, I'd love to hear it.