File: using_client_ssl_certificates.py

package info (click to toggle)
librepo 1.20.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,028 kB
  • sloc: ansic: 18,802; python: 3,822; xml: 581; sh: 142; makefile: 64
file content (27 lines) | stat: -rw-r--r-- 873 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python3

"""
librepo - download a package using client SSL certificate
"""
import librepo


if __name__ == "__main__":

    h = librepo.Handle()
    h.setopt(librepo.LRO_REPOTYPE, librepo.LR_YUMREPO)
    h.setopt(librepo.LRO_URLS, ["https://my-ssl-repo/fedora/20/x86_64/os/"])

    # The client certificate .pem file may include just the public certificate
    # or may include an entire certificate chain including
    # public key, private key, and root certificates.
    h.setopt(librepo.LRO_SSLCLIENTCERT, "/etc/pki/client.pem")

    # In case the .pem just contains the public key, set the private key
    h.setopt(librepo.LRO_SSLCLIENTKEY, "/etc/client.key")

    # Set the certificate authority
    h.setopt(librepo.LRO_SSLCACERT, "/etc/ca.pem")

    h.progressdata = "i2c-tools-eepromer"
    h.download("packages/i2c-tools-eepromer-24-1.x86_64.rpm")