dev-mysql-tlsclient

Mysql with TLS and a TlsClient

Edition for Development of A. Client for MySql using TLSClient and B. any Client using TLSClient

This is a development edition. Upgraded MySql and also using native TLS. A TLSCLient without openssl. All native crystal. Far from production.

ONE

The content here is as follows

(tree -L 2)

── APPLICS
│   ├── MYSQL
│   ├── web1
│   ├── web2
│   └── web3
├── LIBS
│   ├── librfc8439
│   ├── mysql
│   ├── shared
│   └── tlsclient
└── README.md

mysql holds

  1. mixed (local and remote)
  2. localonly (local only. to tryout)
  3. remoteomly (remote ony. to tryout)

LIBS holds

  1. librfc8439 (source git but with extensions)
  2. mysql
  3. shared
  4. tlsclient

Build test applictions

Walk through *.yml

Before you can start building you must look into all shard.yml because there are dependencies using path like:

(one for each APPL/* and one for each LIBS/*)

dependencies:
  tlsclient:
    path: <your path to this folder>/LIBS/tlsclient

Build libraries

for each LIBS
 shards update
 crystal docs

Build applications

for each APPLIC
 shards update
 shards build

Then just try build one, with or without debug options, for mysql (application 'mixed' )

You can include debug trace for each library if you compile with -Dtrctls -Dtrcsql -Dtrcshared

<>APPLICS/MYSQL/mixed> shards update
<>APPLICS/MYSQL/mixed> shards build
<>APPLICS/MYSQL/mixed> shards build --debug
<>APPLICS/MYSQL/mixed> shards build --debug -Dtrcsql -Dtrcshared

Set up MySql server to accept tls

Edit /opt/homebrew/etc/my.cnf to hold

# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
# bind-address = 0.0.0.0 -->
# mysqlx-bind-address = 127.0.0.1
# Allow tls connection
ssl_ca=ca.pem
ssl_cert=server-cert.pem
ssl_key=server-key.pem
tls_version=TLSv1.2,TLSv1.3
require_secure_transport=ON

and run it with proper parameters

<>APPLICS/MYSQL/mixed> ./bin/mixed "url to database" "sql statement"
<>APPLICS/MYSQL/mixed> ./bin/mixed 7 # precompiled test number 7

Example

<>APPLICS/MYSQL/mixed> ./bin/mixed "mysql://root:___@localhost/information_schema" "SELECT table_name FROM columns"

More to do

There are some unresolved issues

  1. APPLIC/web1: several web sites are hard to set up to a proper connection. This application 'APPLIC/web1' and the next 'APPLIC/MYSQL/mixed' use the same LIBS/tlsclient. 'APPLIC/MYSQL/mixed' works fine using tls but 'APPLIC/web1' struggles
  2. APPLIC/MYSQL/mixed: two use case are not verified
  3. Running mysql through firewall/proxy and tls is not tested.

Besides that there sevaral points to work on

  1. Comments in general
  2. Optimize LIBS/shared/*.cr to utilize hardware around crypto functions
  3. This edition is build on MacOs Sequoia 15.3.2 (24D81) and Crystal 1.14.0 (2024-10-09)
  4. No windows or bigendian is verified
  5. Raise is not clever used at the moment
  6. Extend the spec folder

Tools

Source examin

crystal tool unreachable src/mysql.cr

crystal tool hierarchy src/web1.cr -e TLSClient

crystal tool dependencies src/mysql.cr

CSV to 'everything'

https://tableconvert.com/csv-to-html

Analyze ASN.1 things

https://sandbox.swedenconnect.se/cap/asn1

TWO Edition

Rename a file in git

git mv LIBS/mysql/src/mysql/connectionnyare.cr LIBS/mysql/src/mysql/connection.cr

Repository

dev-mysql-tlsclient

Owner
Statistic
  • 0
  • 0
  • 0
  • 0
  • 0
  • 1 day ago
  • January 30, 2026
License

Links
Synced at

Fri, 30 Jan 2026 22:52:34 GMT

Languages