JuliaDatabases / DBInterface.jl

Database interface definitions for Julia
https://juliadatabases.org/DBInterface.jl/dev/
Other
84 stars 12 forks source link

SSL required for connection #25

Closed vacquah closed 4 years ago

vacquah commented 4 years ago

How do you handle when ssl is required for DBInterface.connect ? I am getting an access denied message when trying to connect to a mysql database. I am able to connect to the same database with my database client (datagrip) by setting useSSL = "TRUE" in the clients configuration. Not sure how to set the same here ...

quinnj commented 4 years ago

See the documentation for DBInterface.connect for MySQL connections: https://juliadatabases.github.io/MySQL.jl/dev/#DBInterface.connect.

vacquah commented 4 years ago

My apologies @quinnj. I read through that documentation and didnt quite understand it. There are no examples of how to specify ssl enforcement - it simply says ssl_enforce:::bool. I tried ssl_enforce = true, and it didnt work. I am quite new at all this so hoping you'd point me to an example code.

vacquah commented 4 years ago

if I do ssl_enforce == true, I get:

MethodError: no method matching pointer(::Bool)
Closest candidates are:
  pointer(!Matched::String) at strings/string.jl:81
  pointer(!Matched::String, !Matched::Integer) at strings/string.jl:82
  pointer(!Matched::SubString{String}) at strings/substring.jl:113
  ...
quinnj commented 4 years ago

I'm not super familiar w/ how SSL works for MySQL client-side, but you can checkout the documentation here: https://dev.mysql.com/doc/refman/8.0/en/mysql-options.html for my info. In particular, checkout the MYSQL_OPT_SSL_* options; I think you probably need to pass your private key ssl file and that should do it?

vacquah commented 4 years ago

I actually just need to set ssl_enforce, I think. When using a regular desktop client to connect to the same db, I dont need to pass the private key. I just set sslmode=require.

I see you have ssl_enforce as part of the parameters I can pass in the connection string but I am not sure how that should be set . I have tried all values and still not working.

quinnj commented 4 years ago

Ah, thanks for telling me about the error; I've pushed a fix for that here: https://github.com/JuliaDatabases/MySQL.jl/commit/340a4f1142a2346b169fca05ea92fad4309c6023. If you pull master of MySQL, then you should be able to try ssl_enforce=true. You can pull master by doing ] add MySQL#master

vacquah commented 4 years ago

@quinnj happy to report its working! your timely help is much appreciated! There seems to be the same issue with the LibPQ package when connecting to a postgres db.