Java (since Java 9) have officially deprecated the proprietary JKS format in favor of the industry-standard PKCS12 (.p12 / .pfx) format.
We can use LetsEncrypt to generate the keystore.p12 file.
We can also use JDK keytool to create our self-signed keystore.p12?
Then we can use it directly in B4J server to provide ssl connection (without need to convert it to jks format).
https://www.b4x.com/android/forum/threads/server-ssl-connections.40130/
Am I right?
We can use LetsEncrypt to generate the keystore.p12 file.
LetsEncrypt (Linux):
root@hostname:/etc/letsencrypt/live/domain.com#openssl pkcs12 -export -out /home/keystore.p12 -in fullchain.pem -inkey privkey.pem -name jetty
Laragon (Windows):
C:\laragon\bin\apache\httpd-2.4.68-260617-Win64-VS18\bin>openssl pkcs12 -export -out C:\Projects\EndsMeet\source\Objects\keystore.p12 -in C:\laragon\etc\ssl\laragon.crt -inkey C:\laragon\etc\ssl\laragon.key -name jetty
We can also use JDK keytool to create our self-signed keystore.p12?
B4X:
C:\Java\jdk-19.0.2\bin\keytool -genkeypair -alias jetty -keyalg RSA -keysize 2048 -keystore keystore.p12 -storetype PKCS12 -validity 3650
Then we can use it directly in B4J server to provide ssl connection (without need to convert it to jks format).
ConfigureSSL:
Private Sub ConfigureSSL (SslPort As Int)
'example of SSL connector configuration
Dim ssl As SslConfiguration
ssl.Initialize
ssl.SetKeyStorePath(File.DirApp, "keystore.p12") 'path to keystore file
ssl.KeyStorePassword = "123456"
ssl.KeyManagerPassword = "654321"
srvr.SetSslConfiguration(ssl, SslPort)
'add filter to redirect all traffic from http to https (optional)
srvr.AddFilter("/*", "HttpsFilter", False)
End Sub
Am I right?
Last edited: