Menu

SSL connection patch

Help
2003-05-16
2012-09-19
  • Greg Fortune

    Greg Fortune - 2003-05-16

    I think I've got a working patch to allow MySQLdb to use SSL connections, but I don't have a SSL enabled server to test it against yet.  Anyone want to test the patch or give me a user/pass into a properly setup server so I can test it?  Reply to lists@gregfortune.com if you'd like to do either.

     
    • Anonymous

      Anonymous - 2003-10-23

      Hi greg can you please post your SSL patch in the forum?

       
    • Greg Fortune

      Greg Fortune - 2003-11-03

      Ok, here's what I worked on earlier.  As I remember, it didn't function correctly in some installations (it might fail to compile with MySQL 3.23.x).  Also, I haven't had a chance to test as I haven't had both a client and a server running MySQL 4.0 with SSL to test with except on the local machine. 

      There is a good chance my patch doesn't work correctly as limited testing on my local machine still showed it transmitting plain text so don't use this in a production environment until you've tested it completely.  I may be that you have to connect to a remote machine for SSL to kick in...

      Also, I bumped the version number to 0.9.3 because Andy had not released a new version but he has since released a new version and my version number conflicts.  Sorry.

      Hopefully, the text posts without wrapping too badly.  If you have a couple SSL capable machines that you want to test with, let me know and I'll send the patch via e-mail.  Doesn't look very nice on the posting form so fingers crossed that it looks nice after I click the little button ;o)

      diff -u MySQL-python-0.9.2/PKG-INFO MySQL-python-0.9.3/PKG-INFO
      --- MySQL-python-0.9.2/PKG-INFO    2002-08-01 07:48:50.000000000 -0700
      +++ MySQL-python-0.9.3/PKG-INFO    2003-05-16 14:09:33.000000000 -0700
      @@ -1,6 +1,6 @@
      Metadata-Version: 1.0
      Name: MySQL-python
      -Version: 0.9.2
      +Version: 0.9.3
      Summary: Python interface to MySQL
      Home-page: http://sourceforge.net/projects/mysql-python
      Author: Andy Dustman
      diff -u MySQL-python-0.9.2/_mysql.c MySQL-python-0.9.3/_mysql.c
      --- MySQL-python-0.9.2/_mysql.c    2002-07-31 22:01:30.000000000 -0700
      +++ MySQL-python-0.9.3/_mysql.c    2003-05-15 17:52:36.000000000 -0700
      @@ -1,5 +1,5 @@
      -#define version_info "(0,9,2,'final',1)"
      -#define __version__ "0.9.2"
      +#define version_info "(0,9,3,'beta-ssl',1)"
      +#define __version__ "0.9.3"
      /*
      This program is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
      @@ -278,24 +278,24 @@
           uint client_flag = 0;
           static char *kwlist[] = { "host", "user", "passwd", "db", "port",
                         "unix_socket", "conv",
      -                  "connect_timeout", "compress",
      +                  "connect_timeout", "compress", "ssl",
                         "named_pipe", "init_command",
                         "read_default_file", "read_default_group",
                         NULL } ;
           int connect_timeout = 0;
      -    int compress = -1, named_pipe = -1;
      +    int compress = -1, named_pipe = -1, ssl = -1;
           char *init_command=NULL,
                *read_default_file=NULL,
                *read_default_group=NULL;
          
           self->converter = NULL;
           self->open = 0;
      -    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ssssisOiiisss:connect",
      +    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ssssisOiiiisss:connect",
                            kwlist,
                            &host, &user, &passwd, &db,
                            &port, &unix_socket, &conv,
                            &connect_timeout,
      -                     &compress, &named_pipe,
      +                     &compress, &ssl, &named_pipe,
                            &init_command, &read_default_file,
                            &read_default_group))
               return -1;
      @@ -322,6 +322,8 @@
               mysql_options(&(self->connection), MYSQL_OPT_COMPRESS, 0);
               client_flag |= CLIENT_COMPRESS;
           }
      +    if (ssl != -1)
      +        client_flag |= CLIENT_SSL;
           if (named_pipe != -1)
               mysql_options(&(self->connection), MYSQL_OPT_NAMED_PIPE, 0);
           if (init_command != NULL)
      Only in MySQL-python-0.9.3: build
      Common subdirectories: MySQL-python-0.9.2/doc and MySQL-python-0.9.3/doc
      diff -u MySQL-python-0.9.2/setup.py MySQL-python-0.9.3/setup.py
      --- MySQL-python-0.9.2/setup.py    2002-07-18 12:55:36.000000000 -0700
      +++ MySQL-python-0.9.3/setup.py    2003-11-02 23:37:11.000000000 -0800
      @@ -12,13 +12,14 @@

      # set this to YES if you have the thread-safe mysqlclient library
      thread_safe_library = YES
      +ssl = YES

      # You probably don't have to do anything past this point. If you
      # do, please mail me the configuration for your platform. Don't
      # forget to include the value of sys.platform and os.name.

      name = "MySQL-%s" % os.path.basename(sys.executable)
      -version = "0.9.2"
      +version = "0.9.3"

      mysqlclient = thread_safe_library and "mysqlclient_r" or "mysqlclient"

      @@ -34,6 +35,8 @@

      # MySQL-3.23 and newer need libz
      libraries = [mysqlclient, "z"]
      +if(ssl):
      +    libraries.append("ssl")

      # On some platorms, this can be used to find the shared libraries
      # at runtime, if they are in a non-standard location. Doesn't

       
      • Greg Fortune

        Greg Fortune - 2003-11-03

        Oh beautiful, badly borked :(

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.