#!/usr/bin/python
import ssl
cert = ssl.get_server_certificate(('host', 443))
with open('/usr/lib/python2.7/site-packages/requests/cacert.pem', 'a') as f:
f.write(cert)