{"id":19049284,"url":"https://github.com/cppforlife/mysql-proxy","last_synced_at":"2025-08-01T05:33:03.362Z","repository":{"id":65349668,"uuid":"152154240","full_name":"cppforlife/mysql-proxy","owner":"cppforlife","description":"MySQL proxy for terminating TLS","archived":false,"fork":false,"pushed_at":"2023-10-16T10:59:07.000Z","size":12,"stargazers_count":10,"open_issues_count":2,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-24T01:05:29.772Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cppforlife.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-08T22:25:26.000Z","updated_at":"2024-04-09T17:13:04.000Z","dependencies_parsed_at":"2024-11-08T23:10:34.467Z","dependency_job_id":"80bc14ed-c9f3-4542-b530-ebfc60deacaf","html_url":"https://github.com/cppforlife/mysql-proxy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cppforlife%2Fmysql-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cppforlife%2Fmysql-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cppforlife%2Fmysql-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cppforlife%2Fmysql-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cppforlife","download_url":"https://codeload.github.com/cppforlife/mysql-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250540948,"owners_count":21447427,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T23:10:25.863Z","updated_at":"2025-04-24T01:05:29.995Z","avatar_url":"https://github.com/cppforlife.png","language":"Go","readme":"## mysql-proxy\n\nMySQL proxy that terminates TLS before proxying connection to MySQL server (without TLS). It does not require any changes to server or clients.\n\n```bash\n$ go build proxy.go\n$ ./proxy 3306 3307 ./server.crt ./server.key\n```\n\n## Protocol\n\n### No TLS\n\nProxy forwards initial handshakes and auth results without any modifications.\n\n```\nServer     Proxy      Client\n  \u003c-----------------------        tcp connection initiated\n  -----------------------\u003e        server sends handshake packet\n  \u003c-----------------------        client responds with full handshake (with hashed password)\n  -----------------------\u003e        if password is correct, reply with auth ok\n  (packet seq reset to 0)\n  (copying both ways)\n```\n\n### With TLS\n\nWithout proxy:\n\n```\nServer                Client\n  \u003c-----------------------        tcp connection initiated\n  -----------------------\u003e        server sends handshake packet\n  \u003c-----------------------        client responds with short handshake\n  \u003c-----------------------        tls connection initialized\n  \u003c-----------------------        client responds with full handshake\n  -----------------------\u003e        if password is correct, reply with auth ok\n  (packet seq reset to 0)\n  (copying both ways)\n```\n\nProxy drops client's short handshake and rewrites full handshake packet to disable SSL.\n\n```\nServer     Proxy      Client\n  \u003c-----------------------        tcp connection initiated\n  -----------------------\u003e        server sends handshake packet\n             \u003c------------        client responds with short handshake\n                                  proxy will drop short handshake\n                                  proxy prepares to receive tls handshake from client\n             \u003c------------        tls connection initialized\n  \u003c-------- ~~~ \u003c---------        client responds with full handshake\n                                  proxy rewrites packet seq number\n                                  proxy removes \"client supports ssl\" flag\n  --------\u003e ~~~ ---------\u003e        if password is correct, server replies with auth ok\n                                  proxy rewrites packet seq number\n  (packet seq reset to 0)\n  (copying both ways)\n```\n\nReference:\n\n- [go-sql-driver/mysql's writeHandshakeResponsePacket](https://github.com/go-sql-driver/mysql/blob/7ac0064e822156a17a6b598957ddf5e0287f8288/packets.go#L246)\n- [mysql's packet-Protocol::SSLRequest](https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::SSLRequest)\n\n## TODO\n\n- add connection deadlines\n- set connection tcp keepalive\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcppforlife%2Fmysql-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcppforlife%2Fmysql-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcppforlife%2Fmysql-proxy/lists"}