mysql-source-ssl.td 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. # Test creating a MySQL source using SSH and SSL options
  10. # More comprehensive SSL option tests are in
  11. # `test/mysql-cdc/15-create-connection-tls.td`
  12. > CREATE SECRET ssl_ca AS '${arg.ssl-ca}'
  13. > CREATE SECRET ssl_client_cert AS '${arg.ssl-client-cert}'
  14. > CREATE SECRET ssl_client_key AS '${arg.ssl-client-key}'
  15. # Basic TLS
  16. > CREATE CONNECTION mysql_ssl TO MYSQL (
  17. HOST mysql,
  18. USER root,
  19. PASSWORD SECRET mysqlpass,
  20. SSH TUNNEL thancred,
  21. SSL MODE required
  22. );
  23. > DROP CONNECTION mysql_ssl;
  24. # TLS with CA verification and a client cert
  25. > CREATE CONNECTION mysql_ssl TO MYSQL (
  26. HOST mysql,
  27. USER root,
  28. PASSWORD SECRET mysqlpass,
  29. SSL MODE verify_ca,
  30. SSL CERTIFICATE AUTHORITY SECRET ssl_ca,
  31. SSL CERTIFICATE SECRET ssl_client_cert,
  32. SSL KEY SECRET ssl_client_key
  33. );
  34. $ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
  35. $ mysql-execute name=mysql
  36. DROP DATABASE IF EXISTS tls_schema;
  37. CREATE DATABASE tls_schema;
  38. USE tls_schema;
  39. CREATE TABLE tls_data (f1 INTEGER);
  40. INSERT INTO tls_data VALUES (1), (2);
  41. COMMIT;
  42. > CREATE SOURCE mysql_source_ssl FROM MYSQL
  43. CONNECTION mysql_ssl;
  44. > CREATE TABLE tls_data FROM SOURCE mysql_source_ssl (REFERENCE tls_schema.tls_data);
  45. > SELECT COUNT(*) FROM tls_data;
  46. 2
  47. # TODO: Figure out how to test the Verify_Identity SSL Mode with the auto-generated certs
  48. # created by MySQL. They use an odd CN value in the CA cert:
  49. # https://dev.mysql.com/doc/refman/8.3/en/creating-ssl-rsa-files-using-mysql.html#creating-ssl-rsa-files-using-mysql-ssl-and-rsa-file-characteristics