Jump to content

SSL connection to mysql database via remote site


jaysaurus

Recommended Posts

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...