I had working infrastructure of unity android app and site api working under http
.
Recently I have switched the server and applied ssl certificate
. Now my api is under https
.
In unity app I'm using UnityWebRequest
to communicate with my api. The logical change after switching to https
will be changing all api addressees within the app from http
to https
. I did this, but my api is behaving weirdly. (Giving my own error status as a response all the time, whereas giving good response on old server without certificate.)
Is there anything extra I need to change with the switch to https
?
Usually Unity would handle the certificate automatically and validate it against known root certificates or ignore them completely depending on the platform:
Using a self-signed certificate, however, will fail if Unity decides for the first.
So, for
https
with a self-signed certificate you might have to implement aCertificateHandler
that implements the methodValidateCertificate
.You could either simply bypass the certificate by accepting them all (which is easier but ofcourse would make the
https
kind of pointless)Or try this example from the docs with your public key
And add it to your request
So on Android you should be fine.
The
CertificateHandler
is by default automatically disposed together with theUnityWebRequest
so there is no more to do.