Skip to content

Commit

Permalink
postgres provider: add support for verify-ca and verify-full ssl modes
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 25, 2016
1 parent 17f20bb commit 31e43a9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion python/core/qgsdatasourceuri.sip
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class QgsDataSourceURI
%End

public:
enum SSLmode { SSLprefer, SSLdisable, SSLallow, SSLrequire };
enum SSLmode { SSLprefer, SSLdisable, SSLallow, SSLrequire, SSLverifyCA };

//! default constructor
QgsDataSourceURI();
Expand Down
10 changes: 9 additions & 1 deletion src/core/qgsdatasourceuri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ QgsDataSourceURI::QgsDataSourceURI( QString uri )
mSSLmode = SSLprefer;
else if ( pval == "require" )
mSSLmode = SSLrequire;
else if ( pval == "verify-ca" )
mSSLmode = SSLverifyCA;
else if ( pval == "verify-full" )
mSSLmode = SSLverifyFull;
}
else if ( pname == "requiressl" )
{
Expand Down Expand Up @@ -499,9 +503,13 @@ QString QgsDataSourceURI::connectionInfo( bool expandAuthConfig ) const
else if ( mSSLmode == SSLrequire )
connectionItems << "sslmode=require";
#if 0
else if ( mSSLmode == SSLprefer )
else if ( mSSLmode == SSLprefer ) // no need to output the default
connectionItems << "sslmode=prefer";
#endif
else if ( mSSLmode == SSLverifyCA )
connectionItems << "sslmode=verify-ca";
else if ( mSSLmode == SSLverifyFull )
connectionItems << "sslmode=verify-full";

if ( !mAuthConfigId.isEmpty() )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsdatasourceuri.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
class CORE_EXPORT QgsDataSourceURI
{
public:
enum SSLmode { SSLprefer, SSLdisable, SSLallow, SSLrequire };
enum SSLmode { SSLprefer, SSLdisable, SSLallow, SSLrequire, SSLverifyCA, SSLverifyFull };

//! default constructor
QgsDataSourceURI();
Expand Down
2 changes: 2 additions & 0 deletions src/providers/postgres/qgspgnewconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ QgsPgNewConnection::QgsPgNewConnection( QWidget *parent, const QString& connName
cbxSSLmode->addItem( tr( "allow" ), QgsDataSourceURI::SSLallow );
cbxSSLmode->addItem( tr( "prefer" ), QgsDataSourceURI::SSLprefer );
cbxSSLmode->addItem( tr( "require" ), QgsDataSourceURI::SSLrequire );
cbxSSLmode->addItem( tr( "verify-ca" ), QgsDataSourceURI::SSLverifyCA );
cbxSSLmode->addItem( tr( "verify-full" ), QgsDataSourceURI::SSLverifyFull );

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

0 comments on commit 31e43a9

Please sign in to comment.