I've got this working on the Unix-y platforms, but of course Windows is giving me issues.

Using File::Temp to write the certs to the filesystem works just fine, but when I try to pass them in as a connection string with $file_temp->filename, the drive letter is stripped and the path is, in general, unusable.

For example, if I write the cert out using:

my $mysql_ssl_ca_fh = File::Temp->new( UNLINK => 1, SUFFIX => '.pem'); my $mysql_ssl_ca_file = $mysql_ssl_ca_fh->filename; print $mysql_ssl_ca_fh $SSL_CA_FILE_STRING;

I'll get a randomly-named file (for the purpose of this post, let's call it "foo.pem") in C:\ that contains the contents of $SSL_CA_FILE_STRING.

However, when I try to read it back in, like so:

sub dbconnect { my $engine = shift; my $dsn = q{dbi:mysql:database=database;} . q{host=} . $engine . q{;port=3306} . q{;mysql_ssl=1} . q{;mysql_ssl_ca_file=} . $mysql_ssl_ca_file . q{;mysql_ssl_client_cert=} . $mysql_ssl_cert_file . q{;mysql_ssl_client_key=} . $mysql_ssl_key_file . q{;mysql_ssl_cipher=} . $SSL_CIPHER; my $dbuser = q{supportclient}; my $dbpw = q{}; my $dbh = DBI->connect( $dsn, $dbuser, $dbpw ) || confess; return $dbh; }

I would expect $mysql_ssl_ca_file to contain the value "C:\foo.pem", but it instead contains "\foo.pem", so perhaps File::Temp isn't compatible with Windows paths. Not that it matters. When I try to debug the DSN connection string using dbish, as I normally do, it doesn't seem to understand Windows paths either, so I'm at a loss.

Anyone have any suggestions for how I can create a path to a file on a Windows filesystem that will work in a DBD::mysql DSN? It's not clear from the docs (or maybe I'm not looking in the right place) what the expected format is. The only thing that seems to work (dbish-wise) is being in the same directory as the cert files, and not using any paths.


In reply to Re^3: DBD::mysql w/SSL certs extracted from variables by wwinfrey
in thread DBD::mysql w/SSL certs extracted from variables by wwinfrey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.