B4J Question [SERVER] SSL Connection

T201016

Active Member
Licensed User
Longtime User
Hi,
When using an SSL connection, I get an error when compiling:

2020-08-31 19:11:39.833:INFO::main: Logging initialized @182ms to org.eclipse.jetty.util.log.StdErrLog
sie 31, 2020 7:11:40 PM com.mchange.v2.log.MLog
INFO: MLog clients using java 1.4+ standard logging.
sie 31, 2020 7:11:40 PM com.mchange.v2.c3p0.C3P0Registry
INFO: Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
2020-08-31 19:11:40.728:INFO:eek:ejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 1.8.0_251-b08
2020-08-31 19:11:40.835:INFO:eek:ejs.session:main: DefaultSessionIdManager workerName=node0
2020-08-31 19:11:40.835:INFO:eek:ejs.session:main: No SessionScavenger set, using defaults
2020-08-31 19:11:40.843:INFO:eek:ejs.session:main: node0 Scavenging every 600000ms
2020-08-31 19:11:40.853:INFO:eek:ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@3cb1ffe6{/,file:///C:/Users/OSS/Downloads/B4X_TableSQLite%20Server/Objects/www,AVAILABLE}
2020-08-31 19:11:40.872:INFO:eek:ejs.AbstractNCSARequestLog:main: Opened C:\Users\OSS\Downloads\B4X_TableSQLite Server\Objects\logs\b4j-2020_08_31.request.log
2020-08-31 19:11:40.940:INFO:eek:ejs.AbstractConnector:main: Started ServerConnector@60285225{HTTP/1.1,[http/1.1]}{0.0.0.0:17178}
main._appstart (java line: 90)
java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:340)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:308)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:244)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:398)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at anywheresoftware.b4j.object.ServerWrapper.Start(ServerWrapper.java:220)
at b4j.example.main._appstart(main.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.main(main.java:28)
main.main (java line: 28)
java.lang.RuntimeException: java.net.BindException: Address already in use: bind
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:120)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.main(main.java:28)
Caused by: java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:340)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:308)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:244)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:398)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at anywheresoftware.b4j.object.ServerWrapper.Start(ServerWrapper.java:220)
at b4j.example.main._appstart(main.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
... 2 more

The Keystore key is correctly formed according to the tutorial.
I changed the rdc link to start with https: //

I have a well-configured server,
then this could be because I am trying to use a self-signed certificate?

Browser shows error message:
A secure connection could not be established. An error occurred while connecting to server '127.0.0.1:17178'.
SSL received a record that exceeded the maximum length allowed.

Error code: SSL_ERROR_RX_RECORD_TOO_LONG

The page being opened cannot be displayed because the authenticity of the received data could not be verified.

thank you so much for help.
 

T201016

Active Member
Licensed User
Longtime User
Hello Erel
Thanks a lot for the helpful hint! Of course, I will check how many of these instances have multiplied ...
I wish you a good day :)
 
Upvote 0

T201016

Active Member
Licensed User
Longtime User

I corrected the previous problem according to your suggestion,
but it throws me another error regarding the keystore key.
I used version jre1.8.0_251 to create it, maybe this
must one look for fault in it?

2020-09-01 14:01:14.521:INFO::main: Logging initialized @147ms to org.eclipse.jetty.util.log.StdErrLog
wrz 01, 2020 2:01:14 PM com.mchange.v2.log.MLog
INFO: MLog clients using java 1.4+ standard logging.
wrz 01, 2020 2:01:14 PM com.mchange.v2.c3p0.C3P0Registry
INFO: Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
2020-09-01 14:01:15.118:INFO:eek:ejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 1.8.0_251-b08
2020-09-01 14:01:15.166:INFO:eek:ejs.session:main: DefaultSessionIdManager workerName=node0
2020-09-01 14:01:15.166:INFO:eek:ejs.session:main: No SessionScavenger set, using defaults
2020-09-01 14:01:15.169:INFO:eek:ejs.session:main: node0 Scavenging every 600000ms
2020-09-01 14:01:15.176:INFO:eek:ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@3cb1ffe6{/,file:///C:/Users/OSS/Downloads/B4X_TableSQLite%20Server/Objects/www,AVAILABLE}
2020-09-01 14:01:15.180:INFO:eek:ejs.AbstractNCSARequestLog:main: Opened C:\Users\OSS\Downloads\B4X_TableSQLite Server\Objects\logs\b4j-2020_09_01.request.log
2020-09-01 14:01:15.201:INFO:eek:ejs.AbstractConnector:main: Started ServerConnector@60285225{HTTP/1.1,[http/1.1]}{0.0.0.0:17178}
main._appstart (java line: 90)
java.lang.IllegalStateException: no valid keystore
at org.eclipse.jetty.util.security.CertificateUtils.getKeyStore(CertificateUtils.java:50)
at org.eclipse.jetty.util.ssl.SslContextFactory.loadKeyStore(SslContextFactory.java:1071)
at org.eclipse.jetty.util.ssl.SslContextFactory.load(SslContextFactory.java:262)
at org.eclipse.jetty.util.ssl.SslContextFactory.doStart(SslContextFactory.java:229)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
at org.eclipse.jetty.server.SslConnectionFactory.doStart(SslConnectionFactory.java:72)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:279)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:81)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:244)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:398)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at anywheresoftware.b4j.object.ServerWrapper.Start(ServerWrapper.java:220)
at b4j.example.main._appstart(main.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.main(main.java:28)
main.main (java line: 28)
java.lang.RuntimeException: java.lang.IllegalStateException: no valid keystore
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:120)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.main(main.java:28)
Caused by: java.lang.IllegalStateException: no valid keystore
at org.eclipse.jetty.util.security.CertificateUtils.getKeyStore(CertificateUtils.java:50)
at org.eclipse.jetty.util.ssl.SslContextFactory.loadKeyStore(SslContextFactory.java:1071)
at org.eclipse.jetty.util.ssl.SslContextFactory.load(SslContextFactory.java:262)
at org.eclipse.jetty.util.ssl.SslContextFactory.doStart(SslContextFactory.java:229)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
at org.eclipse.jetty.server.SslConnectionFactory.doStart(SslConnectionFactory.java:72)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:279)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:81)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:244)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:398)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at anywheresoftware.b4j.object.ServerWrapper.Start(ServerWrapper.java:220)
at b4j.example.main._appstart(main.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
... 2 more

1.Created the key using the method:
keytool -genkey -dname "CN=Unknown,O=Unknown,C=Unknown" -keystore mykeystore.keystore -keysize 1024 -alias b4a -validity 14000 -keypass vakoss -storepass vakoss
pause

rem keytool -certreq -keyalg RSA -file mykeystore.csr -keystore mykeystore.keystore
rem pause
2. zainicjowałem w kodzie B4J Souce code:
ssl.SetKeyStorePath(File.DirAssets, "mykeystore.keystore") 'path to keystore file
ssl.KeyStorePassword = "123456"
ssl.KeyManagerPassword = "123456"

Any other hints?
 
Upvote 0
Top