2016-05-17 54 views
3

嘿,我試圖讓URL的頭信息,get_headers():SSL操作失敗,代碼1

當我使用的協議HTTP它的做工精細,但是當我使用https它不工作

的網址:https://200.35.78.130/

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in 
Warning: get_headers(): Failed to enable crypto in 
Warning: get_headers(https://200.35.78.130/): failed to open stream: operation failed in/

這是我的代碼

print_r(get_headers("https://200.35.78.130/", 1)); 

回答

7

釷當您嘗試訪問沒有有效SSL證書的網址時發生錯誤。您可以解決此通過重寫默認的流上下文,這將影響所有後續文件操作(包括遠程URL)

<?php 
stream_context_set_default([ 
    'ssl' => [ 
     'verify_peer' => false, 
     'verify_peer_name' => false, 
    ], 
]); 

print_r(get_headers('https://200.35.78.130/')); 
+0

感謝,它的工作;) –

+0

該死的,5分鐘,讓你所需要的答案 - 這是令人印象深刻。 –