File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
John Landon
Ranch Hand
Posts: 228
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
John Landon
Ranch Hand
Posts: 228
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic