Skip to content
Permalink
Browse files

Issue #704: escape backslashes in SSL certificate files for PostgreSQ…

…L connections
  • Loading branch information...
ansgarbecker committed Oct 11, 2019
1 parent 6c77fc7 commit 0fe7bb66cba163b3e56a9e6831628569bd305e14
Showing with 8 additions and 3 deletions.
  1. +8 −3 source/dbconnection.pas
@@ -2058,6 +2058,11 @@ procedure TPgConnection.SetActive(Value: Boolean);
dbname, ConnInfo, Error, tmpdb: String;
FinalHost: String;
FinalPort: Integer;

function EscapeConnectOption(Option: String): String;
begin // See issue #704
Result := StringReplace(Option, '\', '\\', [rfReplaceAll]);
end;
begin
if Value then begin
DoBeforeConnect;
@@ -2090,11 +2095,11 @@ procedure TPgConnection.SetActive(Value: Boolean);
if FParameters.WantSSL then begin
ConnInfo := ConnInfo + ' sslmode=''require''';
if FParameters.SSLPrivateKey <> '' then
ConnInfo := ConnInfo + ' sslkey='''+FParameters.SSLPrivateKey+'''';
ConnInfo := ConnInfo + ' sslkey='''+EscapeConnectOption(FParameters.SSLPrivateKey)+'''';
if FParameters.SSLCertificate <> '' then
ConnInfo := ConnInfo + ' sslcert='''+FParameters.SSLCertificate+'''';
ConnInfo := ConnInfo + ' sslcert='''+EscapeConnectOption(FParameters.SSLCertificate)+'''';
if FParameters.SSLCACertificate <> '' then
ConnInfo := ConnInfo + ' sslrootcert='''+FParameters.SSLCACertificate+'''';
ConnInfo := ConnInfo + ' sslrootcert='''+EscapeConnectOption(FParameters.SSLCACertificate)+'''';
//if FParameters.SSLCipher <> '' then ??
end;

0 comments on commit 0fe7bb6

Please sign in to comment.
You can’t perform that action at this time.