Giter Club home page Giter Club logo

sslsocket's Introduction

SSLSocket

An SSL socket server and client in JAVA

Installation

git clone https://github.com/williamswhy/SSLSocket.git

Usage

Compile & prepare files

mkdir bin
javac -d bin src/client/*.java
javac -d bin src/server/*.java

Start server & client

server:

java server.SocketListener

client:

java client.SocketClient [address] [port] [message]

Generate SSL

Create a server keystore file:

keytool -genkey -keystore sslserverkeys -keyalg RSA

Export the key as a cert:

keytool -export -keystore sslserverkeys -file cert.cer -keyalg RSA

Add the cert to the trust store of the client:

keytool -import -keystore sslclienttrust -file cert.cer -keyalg RSA

sslsocket's People

Contributors

williamswhy avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

sslsocket's Issues

NoSuchAlgorithmException in Client and Server

Hey,
thanks for the recent commit.

Unfortunately i can't get it to work now.
On both ends (server and client) I get the following exception:

java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
	at java.base/javax.net.ssl.DefaultSSLServerSocketFactory.throwException(SSLServerSocketFactory.java:177)
	at java.base/javax.net.ssl.DefaultSSLServerSocketFactory.createServerSocket(SSLServerSocketFactory.java:190)
	at Server.<init>(Server.java:18)
	at Server.main(Server.java:34)
Caused by: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
	at java.base/java.security.Provider$Service.newInstance(Provider.java:1900)
	at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:236)
	at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:164)
	at java.base/javax.net.ssl.SSLContext.getInstance(SSLContext.java:184)
	at java.base/javax.net.ssl.SSLContext.getDefault(SSLContext.java:110)
	at java.base/javax.net.ssl.SSLServerSocketFactory.getDefault(SSLServerSocketFactory.java:74)
	at Server.<init>(Server.java:17)
	... 1 more
Caused by: java.security.KeyManagementException
	at java.base/sun.security.ssl.SSLContextImpl$DefaultManagersHolder.<clinit>(SSLContextImpl.java:942)
	at java.base/sun.security.ssl.SSLContextImpl$DefaultSSLContext.<init>(SSLContextImpl.java:1112)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
	at java.base/java.security.Provider.newInstanceUtil(Provider.java:155)
	at java.base/java.security.Provider$Service.newInstance(Provider.java:1893)
	... 7 more

I downloaded the sslclienttrust and sslserverkeys from one of your previous commits.
I initialized them like this:
In Server:

System.setProperty("javax.net.ssl.keyStore", "sslserverkeys");
System.setProperty("javax.net.ssl.keyStorePassword", "123456");

In Client:

System.setProperty("javax.net.ssl.trustStore", "sslclienttrust");
System.setProperty("javax.net.ssl.trustStorePassword", "123456");

With your recent readme i can't figure out how to create the required files for client and server.
Could you @mention some information about the proccess, if you're not updating this repo anymore.

Thanks in advance :)

problem

the source code of the client and server are the same

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.