Skip to content

Commit

Permalink
Merge pull request #42 from jumpserver/pr@dev@feat_add_pg_ssl_field
Browse files Browse the repository at this point in the history
feat: 增加 pg ssl 的 mode 字段
  • Loading branch information
Aaron3S committed Sep 13, 2024
2 parents a731cca + 774e191 commit 4d8e978
Show file tree
Hide file tree
Showing 6 changed files with 369 additions and 219 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM jumpserver/chen-base:20240911_113149 AS stage-build
FROM jumpserver/chen-base:20240913_102042 AS stage-build
ENV LANG=en_US.UTF-8

WORKDIR /opt/chen/
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-base
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RUN set -ex \
&& chmod 755 /usr/local/bin/check \
&& rm -f check-${CHECK_VERSION}-linux-${TARGETARCH}.tar.gz

ARG WISP_VERSION=v0.2.0
ARG WISP_VERSION=v0.2.1
RUN set -ex \
&& wget https://github.com/jumpserver/wisp/releases/download/${WISP_VERSION}/wisp-${WISP_VERSION}-linux-${TARGETARCH}.tar.gz \
&& tar -xf wisp-${WISP_VERSION}-linux-${TARGETARCH}.tar.gz -C /usr/local/bin/ --strip-components=1 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.sql.SQLException;
import java.util.Properties;

public class PostgresqlConnectionManager extends BaseConnectionManager {

private static final String jdbcUrlTemplate = "jdbc:postgresql://${host}:${port}/${db}?useUnicode=true&characterEncoding=UTF-8";
Expand Down Expand Up @@ -38,6 +39,7 @@ protected void setSSLProps(Properties props) {
var caCert = (String) this.getConnectInfo().getOptions().get("caCert");
var clientCert = (String) this.getConnectInfo().getOptions().get("clientCert");
var clientKey = (String) this.getConnectInfo().getOptions().get("clientKey");
var sslMode = (String) this.getConnectInfo().getOptions().get("pgSSLMode");

var sslManager = new SSLCertManager();
sslManager.setCaCert(caCert);
Expand All @@ -47,7 +49,7 @@ protected void setSSLProps(Properties props) {

try {
props.setProperty("ssl", "true");
props.setProperty("sslmode", "verify-full");
props.setProperty("sslmode", sslMode);
props.setProperty("sslrootcert", sslManager.getCaCertPath());
props.setProperty("sslcert", sslManager.getClientCertPath());
props.setProperty("sslkey", sslManager.getClientCertKeyPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ private Datasource createDatasource(ServiceOuterClass.TokenResponse tokenResp) {
dbConnectInfo.getOptions().put("caCert", asset.getSpecific().getCaCert());
dbConnectInfo.getOptions().put("clientCert", asset.getSpecific().getClientCert());
dbConnectInfo.getOptions().put("clientKey", asset.getSpecific().getClientKey());
dbConnectInfo.getOptions().put("pgSSLMode", asset.getSpecific().getPgSslMode());
}
return DatasourceFactory.fromConnectInfo(dbConnectInfo);
}
Expand Down
Loading

0 comments on commit 4d8e978

Please sign in to comment.