accepting HTTPS connections with self-signed certificates

前端 未结 13 2098
小蘑菇
小蘑菇 2020-11-22 04:20

I\'m trying to make HTTPS connections, using HttpClient lib, but the problem is that, since the certificate isn\'t signed by a recognized Certificate Authority

13条回答
  •  悲哀的现实
    2020-11-22 05:03

    None of these fixes worked for my develop platform targeting SDK 16, Release 4.1.2, so I found a workaround.

    My app stores data on server using "http://www.example.com/page.php?data=somedata"

    Recently page.php was moved to "https://www.secure-example.com/page.php" and I keep getting "javax.net.ssl.SSLException: Not trusted server certificate".

    Instead of accepting all certificates for only a single page, starting with this guide I solved my problem writing my own page.php published on "http://www.example.com/page.php"

     $b) {
            $post[htmlentities($a)]=htmlentities($b);
        }
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
    
        // receive server response ...
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $server_output = curl_exec ($ch);
        curl_close ($ch);
    
        echo $server_output;
    }
    
    ?>
    

提交回复
热议问题