我有一個問題爲什麼要求ssl認證返回html?
我想要發佈一些數據到網絡服務器並獲得響應。 Webserver有SSL證書驗證,所以我爲它提供文件。在響應中,我應該收到XML文件,但我收到一些HTML。
我小的腳本是這樣的:
import requests, sys, os
program_directory=sys.path[0]
verify = os.path.join(program_directory, "test.pem")
data='some data'
print requests.post('https://somewebsite', data=data, verify=verify).text
這就是我的html之前得到:
C:\Python27\lib\site-packages\requests\packages\urllib3\connection.py:251: SecurityWarning: Certificate has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 for details.) SecurityWarning
如果我使用verify=False
並沒有提供文件,它工作正常,並返回正確的數據。什麼可能是問題,爲什麼我會收到此警告和HTML?
你看過HTML嗎?這是一個很好的機會,它是一個錯誤頁面,表明出了什麼問題。 – 2015-02-24 22:02:04
@JeremyBanks我更新了問題 – tinySandy 2015-02-24 22:05:08
我似乎'請求'(或'urllib3,寧願)抱怨不安全的證書(見[this](https://urllib3.readthedocs.org/en/latest/security.html#不安全的請求警告))。可能是因爲它是自簽名的(未經可信[證書頒發機構](http://en.wikipedia.org/wiki/Certificate_authority)驗證)您可以隨時嘗試添加自己生成的(我猜你可能已經創建一個「本地」證書頒發機構)到urllib3使用的證書頒發機構(檢查[this](https://urllib3.readthedocs.org/en/latest/security.html#using-your-system-s-root-certificates) ) – BorrajaX 2015-02-24 22:41:17