davidepianca98/KMQTT

bug: SSL server certificate not found on iOS

Opened this issue · 5 comments

Hello, I know an issue about this problem (kotlin.Exception: Server certificate path not found) that has been closed one year ago but there is no documentation about where do we need to put the certificate in a KMP project. I tried to put the file in many folders but so far it is not working...

I did this :

tls = TLSClientSettings(
      serverCertificate = Res.getUri("files/ca-certificates.crt"),
),

The file ca-certificates.crt is in my commainMain/commonResources/files folder.

And on Android I don't need to set a certificate, so it does not make sense at all, and I don't even know if the certificate I have a good since I never used one before...

Hello, different platforms may include difference CA certificates and that could be the reason why you are not needing it for Android. I suggest putting the file in resources, reading it to string using the platform specific way and passing the value of the file to TLSClientSettings like this: TLSClientSettings(serverCertificate = certificateContent).
Otherwise you could disable verification by using TLSClientSettings(checkServerCertificate = false) for testing.

I have the same problem in a compose multiplatform application, i don't understand how to pass the certificate, can you update the documentation please ?

@UAndreiRamescu Regarding Compose Multiplatform resources I found the following links:

Once the file has been read, you can just pass the string content to the TLSClientSettings object.

Witch file should I use? .crt or .pem? chain or fullchain?

Only PEM files are accepted. Only the root certificated should be needed. But if not working you could try the full chain.