mysql - docker下带有外部数据库的Apache Guacamole需要SSL数据库连接

标签 mysql docker ssl docker-compose guacamole

背景

  • 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 keystore :

    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
    

    关于mysql - docker下带有外部数据库的Apache Guacamole需要SSL数据库连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60473948/

    相关文章:

    c# - 网络 docker 容器上的 HttpClient 请求

    ssl - 什么可能是这个 : ** Command Error: SSL Error: error:14077410:SSL routines:SSL23_GET_SERVER_HEL LO:sslv3 alert handshake failure 的原因

    .htaccess - 对于使用 .htaccess 输入的任何 URL,强制 SSL 到 www 子域?

    html - 通过 HTTPS 提供的 Word HTML 动态图像显示为已损坏?

    sql - InnoDB 排序真的那么慢吗?

    mysql - 如何选择以查找具有唯一值的日期/时间重叠?

    php - 防止对具有可变(和大)列数的查询进行 sql 注入(inject)

    php - PDO 期望数组在网页上不只返回 1 的 boolean 值

    linux - 我应该在提交之前停止容器吗?

    linux - Docker 不应将新文件写入原始目录