Skip to content

Commit

Permalink
Merge pull request #2842 from jef-n/pg-new-sslmodes
Browse files Browse the repository at this point in the history
postgres provider: add support for verify-ca and verify-full ssl modes (refs #14366)
  • Loading branch information
jef-n committed Feb 26, 2016
2 parents 5b7cfbc + 31e43a9 commit ee4658e
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
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
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
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
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 ee4658e

Please sign in to comment.