It's not a secret anymore!*
The moose likes Sockets and Internet Protocols and the fly likes Opened a socket with ssl. isConnected returns true. But when sending data get 403 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Opened a socket with ssl. isConnected returns true. But when sending data get 403" Watch "Opened a socket with ssl. isConnected returns true. But when sending data get 403" New topic
Author

Opened a socket with ssl. isConnected returns true. But when sending data get 403

John Landon
Ranch Hand

Joined: Sep 25, 2008
Posts: 227
Hi,
I did this with the following VM params:



-Djavax.net.ssl.trustStore=mySrvKeystore -Djavax.net.ssl.trustStorePassword=123456

isConnected is true but when sending data via the channel I get:

HTTP/1.1 403 Forbidden
Content-Type: text/html
Server: Microsoft-IIS/7.5

What I did is in IIS I created a certificate then exported it and imported to my keystore....

Any idea? Because via the browser I can access the server.

Thanks!


Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19684
    
  20

Well, to get an error 403 you must be connected first, so that part is correct.

Error 403 means that you must provide some form of authentication, and you haven't provided the right authentication. Since you say it works just fine in your browser I'm guessing that the website uses NTLM authentication; in other words, your Windows username / password are used. You need to provide them manually. With URLConnection / HttpURLConnection / HttpsURLConnection, java.net.Authenticator would be the way to go. With HttpClient there is class NTCredentials. With direct socket connections, I have no idea how to send the authentication details.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
John Landon
Ranch Hand

Joined: Sep 25, 2008
Posts: 227
Rob Spoor wrote:Well, to get an error 403 you must be connected first, so that part is correct.

Error 403 means that you must provide some form of authentication, and you haven't provided the right authentication. Since you say it works just fine in your browser I'm guessing that the website uses NTLM authentication; in other words, your Windows username / password are used. You need to provide them manually. With URLConnection / HttpURLConnection / HttpsURLConnection, java.net.Authenticator would be the way to go. With HttpClient there is class NTCredentials. With direct socket connections, I have no idea how to send the authentication details.


I can't use that.
This is what I am using now:


I get CONNECT$ED SOCKET. But still 403 or it just gets stuck!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19684
    
  20

As I said before, you will need to send the credentials you need to login with. As you cannot use a higher level of abstraction like HttpClient or even URLConnection, you will need to figure out how to send these credentials manually.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Opened a socket with ssl. isConnected returns true. But when sending data get 403