SSL Operation Failed with Code 1
This PHP code snippet:
$response = file_get_contents("https://maps.co.weber.ut.us/arcgis/rest/services/SDE_composite_locator/GeocodeServer/findAddressCandidates?Street=&SingleLine=3042+N+1050+W&outFields=*&outSR=102100&searchExtent=&f=json");
encounters an error: "SSL operation failed with code 1." This issue is related to the upgrades in PHP 5.6 concerning OpenSSL.
Solution:
To resolve this issue, follow these steps:
Your modified code should look like this:
$arrContextOptions = array( "ssl" => array( "verify_peer" => false, "verify_peer_name" => false, ), ); $response = file_get_contents("https://maps.co.weber.ut.us/arcgis/rest/services/SDE_composite_locator/GeocodeServer/findAddressCandidates?Street=&SingleLine=3042+N+1050+W&outFields=*&outSR=102100&searchExtent=&f=json", false, stream_context_create($arrContextOptions));
Security Implications:
It is important to note that disabling certificate verification has significant security implications. It potentially allows an attacker to use an invalid certificate for eavesdropping. Use this solution only if you thoroughly understand its ramifications and cannot configure your system securely.
The above is the detailed content of Why Does My PHP Code Get an 'SSL Operation Failed with Code 1' Error, and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!