Jump to content

Recommended Posts

Posted

I tested it out a bit myself, and here is what I came up with

#!/usr/bin/python3.10

from __future__ import print_function
import sys
import mysql.connector
from mysql.connector.constants import ClientFlag

print("Content-Type: text/html\n\n")

config = {
    'user': 'krydos_test',
    'password': '<removed>',
    'database': 'krydos_test',
    'host': 'tommy2.heliohost.org',
    'client_flags': [ClientFlag.SSL]
}

cnx = mysql.connector.connect(**config)
cur = cnx.cursor(buffered=True)
cur.execute("show status like 'ssl_cipher'")
print(cur.fetchone())
print("<br>")
cur.execute("select * from test")
result = cur.fetchall()
for row in result:
    print(row)
cur.close()
cnx.close()

You can see the script in action at https://krydos2.heliohost.org/mysql_ssl.py which is running on Johnny and connecting securely to a MySQL database on Tommy. Please note: There are no ca.pem or any other client keys or client certificates needed.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...