Hi All,
I have to connect to a webpage and send some json text. I got a cert file and I have a key file too. This webpage hasn't a login/password method, only the certificate.
The certificate is installed in windows and I can see, that it works. I can use a postman program what can use the same certification, so I think it is good.
I tried Erel's SSLContext - Kickstart example program with mentioned certification, but I can't connect to webpage. I got error message:
In the next code there are a lot of trial and error lines, but no solution yet.
Of course I converted the certificate into pfx and jks too, written in example.
My question is: how can I modify the program to accept this kind of certificate file?
thanks in advance
Steven
I have to connect to a webpage and send some json text. I got a cert file and I have a key file too. This webpage hasn't a login/password method, only the certificate.
The certificate is installed in windows and I can see, that it works. I can use a postman program what can use the same certification, so I think it is good.
I tried Erel's SSLContext - Kickstart example program with mentioned certification, but I can't connect to webpage. I got error message:
B4X:
javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: None of the TrustManagers trust this certificate chain
Of course I converted the certificate into pfx and jks too, written in example.
B4X:
PUBLIC_KEY = File.ReadString(File.DirAssets,"cert.key").Replace(Chr(13),"").Replace(Chr(10),"")
PRIVATE_KEY = File.ReadString(File.DirAssets,"cert.cer").Replace(Chr(13),"").Replace(Chr(10),"")
Dim basicAuth As String
basicAuth = $"${PUBLIC_KEY}:${PRIVATE_KEY}"$ '
Dim job As HttpJob
job.Initialize("",Me)
SetSSLFactory(File.DirAssets,"clientcert.jks","rostasc3")
job.PostString("https://rms.tesztntak.hu/rms/rendeles-osszesito",tj)
'job.GetRequest.SetHeader("Authorization", $"Basic ${su.EncodeBase64(basicAuth.GetBytes("ascii"))}:"$)
job.GetRequest.SetHeader("x-certificate", $"${su.EncodeBase64(basicAuth.GetBytes("ascii"))}:"$)
'job.GetRequest.SetHeader("x-jws-signature", $"${su.EncodeBase64(PRIVATE_KEY.GetBytes("ASCII"))}:"$)
job.GetRequest.SetContentType("application/json")
Wait For (job) JobDone(job As HttpJob)
Log("Result: " & job.Success)
If job.Success Then
Log(job.GetString)
Dim parser As JSONParser
parser.Initialize(job.GetString)
Dim RootMap As Map = parser.NextObject
Else
Log(job.ErrorMessage)
End If
job.Release
thanks in advance
Steven