How do we pass SSL arguments to MySQL in Gramex's FormHandler?

93 Views Asked by At

I'm connecting to a MySQL database for OTP using this gramex.yaml configuration:

otp:
    url: 'mysql+pymysql://$USER:$PASS@$MYSQL_SERVER/$DB'
    table: $TABLE

Whe Gramex starts, it reports an Exception:

InternalError: (pymysql.err.InternalError) (3159, 'Connections using insecure transport are prohibited while --require_secure_transport=ON.')

This answer suggests passing a dummy ssl: dict.

How do I pass this to Gramex's FormHandler?

1

There are 1 best solutions below

0
On

There are 2 possibilities. If you don't have an SSL certificate to connect to the database, use:

otp:
  url: 'mysql+pymysql://$USER:$PASS@$MYSQL_SERVER/$DB'
  table: $TABLE
  connect_args:
    ssl:
      fake_flag_to_enable_tls: true

If you have an SSL CA certificate in a PEM format, use:

otp:
  url: 'mysql+pymysql://$USER:$PASS@$MYSQL_SERVER/$DB'
  table: $TABLE
  connect_args:
    ssl_ca: /path/to/ca-certificate.pem

You may pass any other parameter to the pymysql connection object.