#15 Add the possibility to disable checking the SSL cert
Merged 8 years ago by pingou. Opened 8 years ago by pingou.

file modified
+14 -6
@@ -52,10 +52,13 @@ 

  import mdapi.lib as mdapilib

  import mdapi.file_lock as file_lock

  

- 

  KOJI_REPO = 'https://kojipkgs.fedoraproject.org/repos/'

  PKGDB2_URL = 'https://admin.fedoraproject.org/pkgdb/'

  DL_SERVER = 'http://dl.fedoraproject.org'

+ # Enforce, or not, checking the SSL certs

+ PKGDB2_VERIFY = True

+ # Valid for both koji and the download server

+ DL_VERIFY = True

  

  

  repomd_xml_namespace = {
@@ -153,14 +156,14 @@ 

      status.

      '''

      url = PKGDB2_URL + 'api/collections?clt_status=%s' % status

-     response = requests.get(url)

+     response = requests.get(url, verify=PKGDB2_VERIFY)

      data = response.json()

      return data['collections']

  

  

  def download_db(name, repomd_url, archive):

      print('%s Downloading file: %s' % (name.ljust(padding), repomd_url))

-     response = requests.get(repomd_url)

+     response = requests.get(repomd_url, , verify=DL_VERIFY)

      with open(archive, 'wb') as stream:

          stream.write(response.content)

  
@@ -354,7 +357,7 @@ 

      destfolder, repo = tupl

      url, name = repo

      repomd_url = url + '/repomd.xml'

-     response = requests.get(repomd_url)

+     response = requests.get(repomd_url, verify=DL_VERIFY)

      if not bool(response):

          print('%s !! Failed to get %r %r' % (

              name.ljust(padding), repomd_url, response))
@@ -414,7 +417,6 @@ 

              install_db(name, tempdb, destfile)

  

  

- 

  def main():

      ''' Get the repo metadata. '''

      parser = argparse.ArgumentParser(prog="get_repo_md")
@@ -433,10 +435,16 @@ 

          print('Could not find the configuration file')

          return 1

  

-     global PKGDB2_URL, KOJI_REPO, DL_SERVER

+     global PKGDB2_URL, KOJI_REPO, DL_SERVER, PKGDB2_VERIFY, DL_VERIFY

      PKGDB2_URL = CONFIG.get('PKGDB2_URL', PKGDB2_URL)

      KOJI_REPO = CONFIG.get('KOJI_REPO', KOJI_REPO)

      DL_SERVER = CONFIG.get('DL_SERVER', DL_SERVER)

+     PKGDB2_VERIFY = CONFIG.get('PKGDB2_VERIFY', PKGDB2_VERIFY)

+     DL_VERIFY = CONFIG.get('DL_VERIFY', DL_VERIFY)

+ 

+     if not DL_VERIFY or not PKGDB2_VERIFY:

+         # Suppress urllib3's warning about insecure requests

+         requests.packages.urllib3.disable_warnings()

  

      repositories = []

      # Get the koji repo

no initial comment

perhaps only suppress these warnings if either of the _VERIFY options are False?

Yeah, looks good here. :)

Thanks for the review

Metadata