gpt4 book ai didi

postgresql - SonarQube:如何连接到支持 SSL 的 Google Cloud Postgresql 服务器

转载 作者:行者123 更新时间:2023-11-29 14:26:00 24 4
gpt4 key购买 nike

我已经设置了一个 SonarQube 并配置了 SSL 证书以使用 CertBot 使 URL 始终为 HTTPS .截至目前,PostgreSQL 数据库有一个公共(public) IP,以下是 sonar.properties 文件中更改的值:

sonar.jdbc.username=weakusername
sonar.jdbc.password=strongpassword
sonar.web.host=127.0.0.1
sonar.jdbc.url=jdbc:postgresql://xx.xxx.xxx.xxx/sonarqube

sonar.search.javaOpts=-Xms512m -Xmx512m

# Change max limits
sysctl -w vm.max_map_count=262144

我正在使用 Cloud SQL PostGres作为数据库。我想允许仅 SSL 连接到数据库和 here如何做到这一点,生成客户端证书等。

将“仅允许 SSL 连接”设置为 true 后,我知道有一种方法可以使用描述的客户端证书连接到数据库 here .

下面是启动psql客户端的命令:

psql "sslmode=verify-ca sslrootcert=server-ca.pem \
sslcert=client-cert.pem sslkey=client-key.pem \
hostaddr=[INSTANCE_IP] \
user=postgres dbname=[DB_NAME]"

但是,SonarQube 无法连接到数据库(不确定如何告诉 SonarQube 使用客户端证书)。配置文件中需要进行哪些更改才能使 SonarQube 使用适当的客户端证书并使用 SSL 连接到数据库?

最佳答案

您应该将以下内容添加到 URL:

jdbc:postgresql://xx.xxx.xxx.xxx/sonarqube?ssl=true&sslmode=verify-ca&sslrootcert=/path/to/server-ca.pem&sslkey=/path/to/client-key.pem&sslcert=/path/to/client-cert.pem

请参阅 the available SSL connection parameters 的文档和 SSL client configuration .

关于postgresql - SonarQube:如何连接到支持 SSL 的 Google Cloud Postgresql 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57869137/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com