개발/php
[php] file_get_contents(): SSL operation failed with code 1 에러 해결 방법
효벨
2023. 7. 10. 11:31
728x90
반응형
[php] file_get_contents(): SSL operation failed with code 1 에러 해결 방법
php 에서
html contents 를 가져오고자 할때
file_get_contents 를 많이 사용합니다!
그중에서
아래와 같이 SSL 관련 에러가 나는 경우가 있습니다!
PHP Warning: file_get_contents(): SSL operation failed with code 1
http 도메인은 잘 가져와지는데 https 도메인의 데이터를 가져오고자 할때 위와 같은 에러가 나는데요!
그럴때는 아래와 같이 옵션을 추가해서 호출하시면 됩니다!
$context=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
위 옵션을 추가한 사용법은 아래와 같습니다!
$html = file_get_contents(URL, false, stream_context_create($context));
참고들 하세요!
반응형