mysql - docker下带有外部数据库的Apache Guacamole需要SSL数据库连接
问题描述
背景
- Apache guacamole 使用默认的 guacamole 图像在 docker 下运行。
- 外部 Microsoft Azure 管理的 MySQL 数据库。
- Azure 默认需要 SSL 连接到托管数据库服务。
- 这可以禁用,但这不是此环境的选项。
设置
Docker-compose.yml 有以下部分:
environment:
- "GUACD_HOSTNAME=127.0.0.1"
- "GUACD_PORT=4822"
- "MYSQL_PORT=3306"
- "MYSQL_DATABASE=guacamole"
- "GUACAMOLE_HOME=/data"
- "MYSQL_USER=******************"
- "MYSQL_PASSWORD=******************"
- "MYSQL_HOSTNAME=******************"
问题
在 Azure 中启用它后,我得到以下信息:
guacamole | 09:34:53.998 [http-nio-8080-exec-5] WARN o.a.g.e.AuthenticationProviderFacade - The "mysql" authentication provider has encountered an internal error which will halt the authentication process. If this is unexpected or you are the developer of this authentication provider, you may wish to enable debug-level logging. If this is expected and you wish to ignore such failures in the future, please set "skip-if-unavailable: mysql" within your guacamole.properties.
guacamole | 09:34:53.999 [http-nio-8080-exec-5] ERROR o.a.g.rest.RESTExceptionMapper - Unexpected internal error:
guacamole | ### Error querying database. Cause: java.sql.SQLException: SSL connection is required. Please specify SSL options and retry.
guacamole | ### The error may exist in org/apache/guacamole/auth/jdbc/user/UserMapper.xml
guacamole | ### The error may involve org.apache.guacamole.auth.jdbc.user.UserMapper.selectOne
guacamole | ### The error occurred while executing a query
guacamole | ### Cause: java.sql.SQLException: SSL connection is required. Please specify SSL options and retry.
我知道(在 docker 之外)如果我进行 mysql 客户端命令行连接,我可以使用选项 --ssl ,然后一切正常。
但由于我对 docker 很陌生,我对如何在我的 docker-compose 文件中设置该选项感到困惑。
我的 google fu 让我失望了,让我陷入了关于 TLS 访问 docker 容器或为网站设置 https 的问题。
如何启用 mysql 连接以在我的 docker-compose.yml 中使用 ssl?
解决方案
创建一个包含相关证书的 Java 密钥库:
keytool -import -alias mySQLServerCACert -file /path/to/server-ca.pem -keystore /path/to/jks/truststore.jks
将其添加为卷挂载:
volumes:
- /path/to/jks:/etc/jks
传递附加到数据库名称的 MySQL 配置参数:
MYSQL_DATABASE=guacamole-db?verifyServerCertificate=true&useSSL=true&requireSSL=true&trustCertificateKeyStoreUrl=file:/etc/jks/truststore.jks&trustCertificateKeyStorePassword=password
推荐阅读
- spring-webflux - Spring webflux webclient中是否有类似于RestTemplate中的disableCookieManagement的方法
- javascript - 在 JSX 中映射时 React 函数调用不起作用
- python - StackedWidget 无法正常工作
- javascript - MathJax:是否可以仅突出显示特定元素而不是整个文档?
- android - 分页库仅在房间数据库中存储第一次获取的值
- php - PhpStorm:运行 PHP 服务器不起作用:找不到驱动程序
- c++ - 如何在 clang++ 中干净地进行格式化字符串连接
- c++ - 从当前时间戳计算每日午夜时间
- reactjs - React 和 Nest.js google auth 返回 CORS 错误
- firebase - 没有为“CollectionReference”类型定义方法“document”。颤振/火力基地