title: django.db.utils.OperationalError: (2026, 'SSL connection error: Unable to get certificate')
body: <p>I am trying to get run some tasks in a Django application on Jenkins. Django is failing to connect to the MySQL database on Jenkins(which is on a mac). I should note everything works fine locally. I am going to share some of my settings: </p>
  
  <p><strong>Databases From Settings</strong></p>
  
  <pre><code>DATABASES = {
          'default': {
              'ENGINE': 'django.db.backends.mysql',
              'HOST': '&lt;myhost&gt;',
              'NAME': '&lt;myname&gt;',
              'USER': '&lt;myuser&gt;',
              'OPTIONS': {
                  'ssl': {
                      'ca': os.environ.get('SSL_CA_CERT_PATH'),
                      'cert': os.environ.get('SSL_CLIENT_CERT_PATH'),
                      'key': os.environ.get('SSL_CLIENT_KEY_PATH')
                  }
              }
          }
      }
  </code></pre>
  
  <p>The environment variables for the cert paths do actually seem to work which I find odd. I have debugged with the following python commands in my settings and it does print out the expected results (file paths and file contents): </p>
  
  <pre><code>print(os.environ.get('SSL_CA_CERT_PATH'))
  txt_opn = open(str(os.environ.get('SSL_CA_CERT_PATH')))
  print(txt_opn.read())
  print(os.environ.get('SSL_CLIENT_CERT_PATH'))
  txt_opn = open(str(os.environ.get('SSL_CLIENT_CERT_PATH')))
  print(txt_opn.read())
  print(os.environ.get('SSL_CLIENT_KEY_PATH'))
  txt_opn = open(str(os.environ.get('SSL_CLIENT_KEY_PATH')))
  print(txt_opn.read())
  </code></pre>
  
  <p><strong>Error Message</strong> </p>
  
  <pre><code>django.db.utils.OperationalError: (2026, 'SSL connection error: Unable to get certificate')
  </code></pre>
  
  <p>I have the certs in a Shared folder and chmod 777 everything. I do not have permission to chown to mysql:mysql however, even with sudo: </p>
  
  <pre><code>Sorry, user &lt;myuser&gt; is not allowed to execute '/usr/sbin/chown mysql:mysql client-cert.pem' as root on &lt;myhost&gt;.
  </code></pre>
  
  <p>Lastly, in case is it is relevant, here is what I am running as a jenkins shell script to kick of the tasks. Bare in mind there are many unseen jenkins parameters being used here. Settings is just my --settings, and everything else is pretty self explanatory. </p>
  
  <p><strong>Jenkins Shell Script</strong></p>
  
  <pre><code>export SSL_CA_CERT_PATH=$SSL_CA_CERT_PATH
  export SSL_CLIENT_CERT_PATH=$SSL_CLIENT_CERT_PATH
  export SSL_CLIENT_KEY_PATH=$SSL_CLIENT_KEY_PATH
  
  echo "Making Virtual Environment..."
  /usr/local/bin/virtualenv venv
  source ./venv/bin/activate
  
  echo "Installing Requirements..."
  pip install -r requirements.txt --process-dependency-links
  
  echo "Making Migrations..."
  python manage.py makemigrations $SETTINGS
  
  echo "Migrating Database Schema..."
  python manage.py migrate $SETTINGS
  
  echo "Running Jobs..."
  IFS=',' read -r -a jobs_array &lt;&lt;&lt; "$JOBS"
  for JOB in "${jobs_array[@]}"
  do
    if [ "$GROUPED" = true ]; then
      echo "Preparing to start Job Group $JOB..."
      python manage.py runjobs $JOB $SETTINGS
    else
      echo "Preparing to start $JOB job..."
      python manage.py runjob $JOB $SETTINGS
    fi
  done
  
  echo "Jobs Completed!"
  </code></pre>
  
  <p>I have been searching for an answer far and wide and have yet been able to find something that works. Does anyone have a solution to this problem? </p>