Skip to content

Commit 31e43a9

Browse files
committed
postgres provider: add support for verify-ca and verify-full ssl modes
1 parent 17f20bb commit 31e43a9

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

python/core/qgsdatasourceuri.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class QgsDataSourceURI
1414
%End
1515

1616
public:
17-
enum SSLmode { SSLprefer, SSLdisable, SSLallow, SSLrequire };
17+
enum SSLmode { SSLprefer, SSLdisable, SSLallow, SSLrequire, SSLverifyCA };
1818

1919
//! default constructor
2020
QgsDataSourceURI();

src/core/qgsdatasourceuri.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ QgsDataSourceURI::QgsDataSourceURI( QString uri )
199199
mSSLmode = SSLprefer;
200200
else if ( pval == "require" )
201201
mSSLmode = SSLrequire;
202+
else if ( pval == "verify-ca" )
203+
mSSLmode = SSLverifyCA;
204+
else if ( pval == "verify-full" )
205+
mSSLmode = SSLverifyFull;
202206
}
203207
else if ( pname == "requiressl" )
204208
{
@@ -499,9 +503,13 @@ QString QgsDataSourceURI::connectionInfo( bool expandAuthConfig ) const
499503
else if ( mSSLmode == SSLrequire )
500504
connectionItems << "sslmode=require";
501505
#if 0
502-
else if ( mSSLmode == SSLprefer )
506+
else if ( mSSLmode == SSLprefer ) // no need to output the default
503507
connectionItems << "sslmode=prefer";
504508
#endif
509+
else if ( mSSLmode == SSLverifyCA )
510+
connectionItems << "sslmode=verify-ca";
511+
else if ( mSSLmode == SSLverifyFull )
512+
connectionItems << "sslmode=verify-full";
505513

506514
if ( !mAuthConfigId.isEmpty() )
507515
{

src/core/qgsdatasourceuri.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
class CORE_EXPORT QgsDataSourceURI
3636
{
3737
public:
38-
enum SSLmode { SSLprefer, SSLdisable, SSLallow, SSLrequire };
38+
enum SSLmode { SSLprefer, SSLdisable, SSLallow, SSLrequire, SSLverifyCA, SSLverifyFull };
3939

4040
//! default constructor
4141
QgsDataSourceURI();

src/providers/postgres/qgspgnewconnection.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ QgsPgNewConnection::QgsPgNewConnection( QWidget *parent, const QString& connName
3535
cbxSSLmode->addItem( tr( "allow" ), QgsDataSourceURI::SSLallow );
3636
cbxSSLmode->addItem( tr( "prefer" ), QgsDataSourceURI::SSLprefer );
3737
cbxSSLmode->addItem( tr( "require" ), QgsDataSourceURI::SSLrequire );
38+
cbxSSLmode->addItem( tr( "verify-ca" ), QgsDataSourceURI::SSLverifyCA );
39+
cbxSSLmode->addItem( tr( "verify-full" ), QgsDataSourceURI::SSLverifyFull );
3840

3941
mAuthConfigSelect = new QgsAuthConfigSelect( this, "postgres" );
4042
tabAuthentication->insertTab( 1, mAuthConfigSelect, tr( "Configurations" ) );

0 commit comments

Comments
 (0)