PHP file_get_contents() 에러 메시지 ssl operation failed with code 1. openssl 문구를 만났을 때 처리 방법

PHP 개발작업 중 file_get_contents 함수를 이용해서 데이터를 가져오다보면 가끔 openssl 이슈가 생기곤 합니다. 

PHP 에러 메시지


file_get_contents() ssl operation failed with code 1. openssl

​ 이럴 땐 당황하지 마시고, 다음과 같이 조치하시기 바랍니다. 여러가지 해결 방법이 있을 수 있겠지만, 다음과 같은 방법으로 해결이 되어서 공유하고자 올립니다! 

 JS

$arrContextOptions=array( 
  "ssl"=>array( 
    "verify_peer"=>false, "verify_peer_name"=>false, 
  ),
);

PHP


file_get_contents("url", false, stream_context_create($arrContextOptions));
​ 참고들 하시구요. 도움들 되시길 바랍니다.