-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connection errors when using SubString{String} type #203
Comments
Oh wow, great sleuthing! Hmmm, the result surprises me because I would have thought the ccall conversions would have worked. Let me dig in a bit and see if I can figure out what's going wrong. |
Ah shoot, yep, so we can see the problem with the following: julia> arg = view(" password ", 3:10)
"password"
julia> ptr = convert(Ptr{Cvoid}, pointer(arg))
Ptr{Nothing} @0x00000001190f2e5a
julia> unsafe_string(convert(Ptr{UInt8}, ptr))
"password " so basically, if your SubString has any characters after the last point of the range, they still get included in the ccall convert. |
Ok PR up: #204 |
Thanks, though I tried the latest sout_io = IOBuffer()
serr_io = IOBuffer()
run(pipeline(
`aws rds generate-db-auth-token
--hostname $(ENV["PROXY_ENDPOINT"])
--port $(ENV["DB_PORT"])
--region $(ENV["AWS_DEFAULT_REGION"])
--username $(ENV["DB_USERNAME"])`,
stdout=sout_io,
stderr=serr_io,
))
resp_out = String(take!(sout_io))
resp_err = String(take!(serr_io))
db_auth_token = isempty(resp_out) ? resp_err : resp_out
db_auth_token_stripped = strip(db_auth_token) # must wrap this in String(...) to make the connection work
conn = DBInterface.connect(
MySQL.Connection,
ENV["PROXY_ENDPOINT"],
ENV["DB_USERNAME"],
db_auth_token_stripped;
unix_socket="",
port=parse(Int, string(ENV["DB_PORT"])),
ssl_ca="/runtime/AmazonRootCA1.pem",
ssl_verify_server_cert=true,
ssl_enforce=true
) |
ah, I think we have more places where we need to do this; sorry about that. I was still stuck on the |
I just finished debugging #201 on my end and it turns out that the token problems actually came down to types and the ccalls in this package. If I call
DBInterface.connect
with a password that is a::SubString{String}
, something bad happens to the password and the server believes it to be incorrect. If I convert it to a::String
, all is good.I would suggest changing the types on the C API to be
String
instead ofAbstractString
. I also haven't done a review for other potential gotchas.The text was updated successfully, but these errors were encountered: