How to validate SSL certificate before sending data via https?

My app sends data to a server with a WWWForm. Before I send the data, I’d like to validate that the destination has a valid SSL certificate to prevent the data getting sent to some other untrusted destination (eg. via rewrite rules).

If i understand correctly the WWW object doesn’t automatically handle enforcing SSL certificate validity when dealing with https requests. I’m looking for the simplest possible way enforce this, and to not send the data if no valid certificate is found.

I’ve looked at some .Net documentation for dealing with this kind of scenario but so far I’ve found it difficult to understand. Does anyone have (or could anyone write) some example code demonstrating how this can be achieved in the simplest way? (I’m open to using a paid-for asset if this would make things simpler here).

Here’s a stripped down version of the (no enforcing) code I have at the moment:

    var form:WWWForm = new WWWForm();
    // TODO: Only send data if valid certificate is found
    var www:WWW = new WWW("", form);
    // Wait until the download is done
    yield www;
    if(www.error != null){
    } else {
      // TODO: process www.text here

Hello has anybody solved this problem with WWW and https?

There is error code in Android:

11-18 11:28:09.857    7407-7426/? E/Unity﹕ ParseDataTest: Trust anchor for certification path not found.
    (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 65)

And Unity error code:

arseDataTest: data:SSL: certificate subject name 'localhost' does not match target host name ''

Thank you.