How can we pass SSL parameters to MySQL in Gramex's FormHandler?
P粉558478150
P粉558478150 2024-04-02 16:34:01
0
1
406

I use this gramex.yaml to configure the MySQL database connected to OTP:

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

When 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: dictionary.

How to pass it to Gramex's FormHandler?

P粉558478150
P粉558478150

reply all(1)
P粉592085423

There are two 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 PEM format, use:

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

You can pass any additional parameters to the pymysql connection object .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!