The certificate I purchased (in Apache format) consists of three files: cert.pem, chain.pem and key.key.
Content of the cert.pem file:
Content of the chain.pem file:
I opened and merged them using Notepad (with the certificate content at the beginning and the intermediate chain content at the end), and saved them to a new PEM file(fullchain.pem). Make it look like this:
Then, use OpenSSL to convert it into a PKCS12 format file: jetty.p12
Then, use the keytool tool in the java-jdk to convert the .p12 file into a .keystore file.
Finally, use it in B4J like this
Now there is a problem with the operation:
My B4J version is 10.30 (64-bit)
I'm not sure if this is the result of some mistake I made at a certain step that prevented the program from running.Please help me clarify my doubts, everyone. Thank you.
Content of the cert.pem file:
B4X:
-----BEGIN CERTIFICATE-----
MIIGTw...
-----END CERTIFICATE-----
B4X:
-----BEGIN CERTIFICATE-----
Mag...
-----END CERTIFICATE-----
B4X:
-----BEGIN CERTIFICATE-----
MIIGTw...
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
Magja...
-----END CERTIFICATE-----
Then, use OpenSSL to convert it into a PKCS12 format file: jetty.p12
Bash:
openssl pkcs12 -export -out jetty.p12 -inkey key.key -in fullchain.pem
Then, use the keytool tool in the java-jdk to convert the .p12 file into a .keystore file.
Bash:
keytool -importkeystore -noprompt -srckeystore jetty.p12 -srcstoretype PKCS12 -srcstorepass password -destkeystore test.keystore -deststorepass password
Finally, use it in B4J like this
B4X:
Sub Process_Globals
'CA
Public SslConfiguration As SslConfiguration
Public KeystorePassword As String = "myPassword"
Public KeystoreFilename As String = "test.keystore"
Public srvr As Server
End Sub
Private Sub ConfigureSSL (SslPort As Int)
SslConfiguration.Initialize
SslConfiguration.SetKeyStorePath(File.DirApp, KeystoreFilename)
SslConfiguration.KeyStorePassword = KeystorePassword
SslConfiguration.KeyManagerPassword = KeystorePassword
srvr.SetSslConfiguration(SslConfiguration, SslPort)
srvr.AddFilter("/*", "HttpsFilter", False)
End Sub
Now there is a problem with the operation:
B4X:
java.util.ServiceConfigurationError: org.eclipse.jetty.util.security.CredentialProvider: module b4j does not declare `uses`
at java.base/java.util.ServiceLoader.fail(Unknown Source)
at java.base/java.util.ServiceLoader.checkCaller(Unknown Source)
at java.base/java.util.ServiceLoader.<init>(Unknown Source)
at java.base/java.util.ServiceLoader.load(Unknown Source)
at b4j/org.eclipse.jetty.util.security.Credential.<clinit>(Unknown Source)
at b4j/org.eclipse.jetty.util.ssl.SslContextFactory.newPassword(Unknown Source)
at b4j/org.eclipse.jetty.util.ssl.SslContextFactory.setKeyStorePassword(Unknown Source)
at b4j/anywheresoftware.b4j.object.ServerWrapper$SslContextFactoryWrapper.setKeyStorePassword(Unknown Source)
at b4j/b4j.example.main._configuressl(Unknown Source)
at b4j/b4j.example.main._appstart(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
at b4j/anywheresoftware.b4a.BA.raiseEvent(Unknown Source)
at b4j/b4j.example.main.main(Unknown Source)
My B4J version is 10.30 (64-bit)
I'm not sure if this is the result of some mistake I made at a certain step that prevented the program from running.Please help me clarify my doubts, everyone. Thank you.
Last edited by a moderator: