Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bertrandmartel/socket-multiplatform
Multi-platform Socket connection types
https://github.com/bertrandmartel/socket-multiplatform
Last synced: 4 days ago
JSON representation
Multi-platform Socket connection types
- Host: GitHub
- URL: https://github.com/bertrandmartel/socket-multiplatform
- Owner: bertrandmartel
- License: mit
- Created: 2015-05-14T13:44:36.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-11T19:35:11.000Z (almost 8 years ago)
- Last Synced: 2023-03-01T16:41:57.615Z (over 1 year ago)
- Language: C++
- Homepage:
- Size: 2.79 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Multi-platform Socket connections
http://bertrandmartel.github.io/socket-multiplatform
Last update 23/05/2015
This project will features socket connection implementation on multiple platforms and frameworks :
Java
Browser
C++ QT4
HTTP Server socket
blocking
no ssl
ssl
non-blocking
no ssl
ssl
Server websocket
blocking
no ssl
ssl
non-blocking
no ssl
ssl
HTTP Client socket
no ssl
ssl
Client websocket
no ssl
ssl
UDP server
blocking
no ssl
ssl
non-blocking
no ssl
ssl
UDP Client
no ssl
ssl
Java
Browser
C++ QT4
Description of Java Websocket Server/Client
[JAVA Websocket server sub-project](http://bertrandmartel.github.io/websocket-java/)
Description of C++ QT4 Non-blocking Websocket Server
[C++ QT4 Websocket server sub-project](http://bertrandmartel.github.io/websocket-non-blocking-cpp/)
Description of Java HTTP Server Socket
[JAVA HTTP server socket sub-project](server/server-socket/blocking/java/)
Description of Java HTTP Client Socket
[JAVA HTTP client socket sub-project](client/socket-client/java/)
Description of Java UDP Server/Client Socket
[JAVA UDP client/server socket sub-project](udp/java/)
Description of C++ QT4 Non Blocking HTTP Server socket
[C++ Non Blocking HTTP Server socket](server/server-socket/non-blocking/)
TroubleShooting
Keystore : public and private server certificates
* To convert cert and key certs to p12 :
``openssl pkcs12 -export -out server.p12 -inkey server.key -in server.crt``
Thus, you will have : ``String KEYSTORE_DEFAULT_TYPE = "PKCS12"``
* To convert your p12 (containing public and private cert) to jks :
You have to know your alias (name matching your cert entry), if you dont have it retrieve it with : ``keytool -v -list -storetype pkcs12 -keystore server.p12``
``keytool -importkeystore -srckeystore server.p12 -srcstoretype PKCS12 -deststoretype JKS -destkeystore server.jks``
Thus, you will have : ``String KEYSTORE_DEFAULT_TYPE = "JKS"``
Trustore : should contain only CA certificates
convert ca cert to jks :
```keytool -import -alias ca -file ca.crt -keystore cacerts.jks -storepass 123456```
Thus, you will have : ``String TRUSTORE_DEFAULT_TYPE = "JKS"``
Bad certificate | Unknown CA errors
This could mean you didn't import your not-trusted-CA certificate into your browser.
The remote host closed the connection
Usually happen when your browser closed the connection before the end of SSL handshake. If you already added your CA to your browser dont worry.
Both Chrome and Firefox need to MANUALLY add the certificate (in a popup) so putting it in parameter menu don't change anything.Just load your URL with "https" : https://127.0.0.1:8443 . Browser will prompt you to accept the certificates and it will probably solve your connection error.
CKR_DOMAIN_PARAMS_INVALID error using openjdk
With openjdk-6-jdk and openjdk-7-jdk, I encountered java.security bug described in https://bugs.launchpad.net/ubuntu/+source/openjdk-7/+bug/1006776 triggering a ``CKR_DOMAIN_PARAMS_INVALID`` exception error. Solution was to edit java.security parameters in /etc/java-7-openjdk/security/java.security
I replaced that :
```
security.provider.9=sun.security.smartcardio.SunPCSC
security.provider.10=sun.security.pkcs11.SunPKCS11 ${java.home}/lib/security/nss.cfg
```with that :
```
#security.provider.9=sun.security.smartcardio.SunPCSC
security.provider.9=sun.security.ec.SunEC
#security.provider.10=sun.security.pkcs11.SunPKCS11 ${java.home}/lib/security/nss.cfg
```Browser tested
This has been tested on following browser :
* Chrome
* Chromium
* Firefox
Debugging SSL connection error
I recommmend using openssl command line tool to debug ssl connection :
``openssl s_client -connect 127.0.0.1:8443``
You can also use vm argument debugging java ssl implementation : ``-Djavax.net.debug=ssl``
Server-Client key/cert generation
Certs are in libwesocket-test/certs folder, you will find server,client and ca cert build with easy-rsa :
https://github.com/OpenVPN/easy-rsa
With last release of easy-rsa, you can build your own key with the following :
* ``./build-ca`` : generate a new CA for you
* ``./build-server-full myServer`` : will build for you public cert and private cert signed with CA for server
* ``./build-client-full myClient`` : will build for you public cert and private cert signed with CA for client
Java
* Projects are JRE 1.7 compliant
* You can build with ant => build.xml
* Development on EclipseC++ QT
* Project are Qt4 compliant
* You can build with qmake
* Development on QtCreator