I made my implementation of the HTTP protocol following the specification of the W3C in Java. But I can't handle https connections.
Asked
Active
Viewed 132 times
-3
-
The code you have posted is both irrelevant and wrong. You need to take a really good look at RFC [2616](https://www.ietf.org/rfc/rfc2616.txt) and friends. – user207421 Apr 17 '15 at 23:11
1 Answers
1
There is nothing special about HTTPs when it comes to HTTP protocol. All you need is to open server SSL socket and once the new connection comes, get the socket's input stream and you can use it (maybe after wrapping to buffered input stream) in the same way as for HTTP.
int port = 443;
ServerSocketFactory ssocketFactory = SSLServerSocketFactory.getDefault();
ServerSocket ssocket = ssocketFactory.createServerSocket(port);
Socket socket = ssocket.accept();
EDIT: You might be missing server keystore. Pls try to follow this tutorial: http://stilius.net/java/java_ssl.php i.e.
generate server keystore:
keytool -genkey -keystore mySrvKeystore -keyalg RSA
run your server with proper arguments like:
java -Djavax.net.ssl.keyStore=mySrvKeystore -Djavax.net.ssl.keyStorePassword=123456 EchoServer

sodik
- 4,675
- 2
- 29
- 47
-
I receive this exception: `javax.net.ssl.SSLHandshakeException: no cipher suites in common` – Marcus Becker Apr 17 '15 at 18:22
-
-
Thank you, your answer was very helpful. It took only complete with the two links: [http://stackoverflow.com/questions/15076820/java-sslhandshakeexception-no-cipher-suites-in-common](http://stackoverflow.com/questions/15076820/java-sslhandshakeexception-no-cipher-suites-in-common) and [http://www.javacodegeeks.com/2014/07/java-keystore-tutorial.html](http://www.javacodegeeks.com/2014/07/java-keystore-tutorial.html) – Marcus Becker Apr 20 '15 at 13:23