' creates a certificate with Let's Encrypt
Sub MakeJKS() As Boolean
Dim Result As Boolean
' needs to be the 'entry point' in your webserver (NOT your B4X app). In my case it was var/www/html and not var/www/)
' MUST be accessible on port 80
JKS.Initialize("/www")
Dim domains As List
domains.Initialize
domains.Add("https://mydomain.com")
' when developing, I check here if it is my local PC. If so I do not use the production server of Let's Encrypt
Result = JKS.GenerateJKS(domains, File.DirApp, JKSName, JKSStorePassword, JKSManagerPassword, False, "C:\KeyVault", True)
If File.Exists(File.DirApp, JKSName & ".jks") = False Then
' let's try to make a self signed certificate for development
LogError("Failed to open or create " & JKSName & ".jks with Let's Encrypt. Let's try to make a self signed one...")
Result = JKS.GenerateSelfSignedJKS(File.DirApp, JKSName, JKSStorePassword, JKSManagerPassword, "C:\KeyVault")
End If
Return Result
End Sub
Sub JKSReloadTimer_Tick
If MakeJKS Then
' we created a new one, so reload it in the server
JKS.ReloadJKS(Server.GetSSLConfiguration)
End If
End Sub