Search code examples
sslpython-siphon

How to get siphon to recognize SSL cert bundle


I’m trying to use siphon from behind a pretty aggressive firewall, but I can’t figure out how to get siphon to recognize my SSL certs. Constructing a TDSCatalog fails with

Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])

I verified the certs themselves are good, just not sure how to pass them to siphon


Solution

  • Siphon uses the requests module for HTTP access, and from the docs it looks like you can pass certs to session() to use for HTTPS verification using the verify argument.

    To hook into this for creating HTTP sessions in Siphon, you can access siphon.http_util.session_manager to set some default options, like is done in this example for HTTP authorization. So I think this would work:

    from siphon.catalog import TDSCatalog
    from siphon.http_util import session_manager
    session_manager.set_session_options(verify='path/to/my/cert')
    cat = TDSCatalog('https://myserver.net/thredds/catalog.xml')
    

    I'm not sure what problem you're having exactly, but you may need to use the cert attribute instead of verify.