Skip to content

Request: Connection Example for TLS #103

@dickson-michael

Description

@dickson-michael

I'm trying to debug an issue connecting to a vendor's database, and they recommended connecting with TLS.

Connection worked fine when run against my local Dockerized MySQL-8 container, but when I set the MySQL flag require_secure_transport it would disconnect (HY000 Connections using insecure transport are prohibited), as expected.

I modified the 2-simple-query.php file to read:

$context = (new Socket\ConnectContext)->withTlsContext(new Socket\ClientTlsContext(DB_HOST));
$config = new Mysql\ConnectionConfig(DB_HOST, 3306, DB_USER, DB_PASS, DB_NAME, $context);

However, this results in a promptly closed connection.

Debug output (without TLS context):

81 bytes read (version, caching_sha2_password)
101 bytes written (user, database, caching_sha2_password)
6 bytes read
5 bytes written
456 bytes read (public key)
[etc]

Debug output (with TLS context):

81 bytes read (version, caching_sha2_password)
36 bytes written
[disconnect]

If you can include an example for how to connect to a server that requires secure transport, it would be helpful.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions