SSL connection to MySQL dB failed

I have a python script running on an Amazon EC2 instance (linux) that scrapes the data from a source and outputs a pandas dataframe to me. I want to send this dataframe to MySQL on Amazon RDS. But when I run the script, it throws me the following error:

sqlalchemy.exc.InterfaceError: (mysql.connector.errors.InterfaceError) 2026 (HY000): SSL connection error: SSL_CTX_set_tmp_dh failed

Before executing the script on an ec2 instance, I was running it on my local machine and it was working fine. Meaning, I was able to send the data to the RDS scraped by my scraper. But now that I am running the script on EC2, it is showing me SSL connection errors.

I might not have configured the EC2 instance correctly or might have forgotten to install something. I don't work with SSL much, so I'm finding it difficult figuring out how this is supposed to be set up. Any pointers, even obvious ones, will likely help at this stage.

I have tried some of the solutions that i found on stack but none of them worked. This is my code to connect to the database:

def dbConnect():
    end_point = xxx
    username = xxx
    password = xxx
    port=3306
    global dbname
    dbname=xxx
    conn = pymysql.connect(end_point, user=username,port=port,passwd=password, db=dbname)
    global eng
    eng=create_engine('mysql+mysqlconnector://xxx:xxx@xxx:3306')
    return dbname,eng

1 answer

  • answered 2019-05-22 04:42 Wing

    I have something very similar, although I use PuTTy for the SSL to create a port forwared tunnel.
    Make sure you have the security groups set up correctly between your EC2 instance and RDS too.