Skip to content

Commit 891f8f2

Browse files
committedOct 16, 2017
[auth] Add checkbox to exclud root CAs from bundles on pkipath method
1 parent d293e8f commit 891f8f2

File tree

3 files changed

+80
-29
lines changed

3 files changed

+80
-29
lines changed
 

‎src/auth/pkipaths/qgsauthpkipathsedit.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ QgsAuthPkiPathsEdit::QgsAuthPkiPathsEdit( QWidget *parent )
3636
connect( chkPkiPathsPassShow, &QCheckBox::stateChanged, this, &QgsAuthPkiPathsEdit::chkPkiPathsPassShow_stateChanged );
3737
connect( btnPkiPathsCert, &QToolButton::clicked, this, &QgsAuthPkiPathsEdit::btnPkiPathsCert_clicked );
3838
connect( btnPkiPathsKey, &QToolButton::clicked, this, &QgsAuthPkiPathsEdit::btnPkiPathsKey_clicked );
39+
connect( cbAddCas, &QCheckBox::stateChanged, this, [ = ]( int state ) { cbAddRootCa->setEnabled( state == Qt::Checked ); } );
3940
lblCas->hide();
4041
twCas->hide();
4142
cbAddCas->hide();
43+
cbAddRootCa->hide();
4244
}
4345

4446
bool QgsAuthPkiPathsEdit::validateConfig()
@@ -107,6 +109,7 @@ bool QgsAuthPkiPathsEdit::validateConfig()
107109
lblCas->setVisible( showCas );
108110
twCas->setVisible( showCas );
109111
cbAddCas->setVisible( showCas );
112+
cbAddRootCa->setVisible( showCas );
110113

111114
return validityChange( certvalid );
112115
}
@@ -118,6 +121,7 @@ QgsStringMap QgsAuthPkiPathsEdit::configMap() const
118121
config.insert( QStringLiteral( "keypath" ), lePkiPathsKey->text() );
119122
config.insert( QStringLiteral( "keypass" ), lePkiPathsKeyPass->text() );
120123
config.insert( QStringLiteral( "addcas" ), cbAddCas->isChecked() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) );
124+
config.insert( QStringLiteral( "addrootca" ), cbAddRootCa->isChecked() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) );
121125

122126
return config;
123127
}
@@ -131,6 +135,7 @@ void QgsAuthPkiPathsEdit::loadConfig( const QgsStringMap &configmap )
131135
lePkiPathsKey->setText( configmap.value( QStringLiteral( "keypath" ) ) );
132136
lePkiPathsKeyPass->setText( configmap.value( QStringLiteral( "keypass" ) ) );
133137
cbAddCas->setChecked( configmap.value( QStringLiteral( "addcas" ), QStringLiteral( "false " ) ) == QStringLiteral( "true" ) );
138+
cbAddRootCa->setChecked( configmap.value( QStringLiteral( "addrootca" ), QStringLiteral( "false " ) ) == QStringLiteral( "true" ) );
134139

135140
validateConfig();
136141
}

‎src/auth/pkipaths/qgsauthpkipathsedit.ui

Lines changed: 67 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>449</width>
10-
<height>260</height>
9+
<width>415</width>
10+
<height>268</height>
1111
</rect>
1212
</property>
1313
<layout class="QGridLayout" name="gridLayout">
@@ -51,7 +51,7 @@
5151
</property>
5252
</widget>
5353
</item>
54-
<item row="2" column="1">
54+
<item row="2" column="1" rowspan="2">
5555
<widget class="QTreeWidget" name="twCas">
5656
<property name="editTriggers">
5757
<set>QAbstractItemView::NoEditTriggers</set>
@@ -75,17 +75,7 @@
7575
</column>
7676
</widget>
7777
</item>
78-
<item row="2" column="2" colspan="2">
79-
<widget class="QCheckBox" name="cbAddCas">
80-
<property name="toolTip">
81-
<string>Add bundle CAs to the connection</string>
82-
</property>
83-
<property name="text">
84-
<string>Add</string>
85-
</property>
86-
</widget>
87-
</item>
88-
<item row="3" column="0">
78+
<item row="4" column="0">
8979
<widget class="QLabel" name="lblPkiPathsKey">
9080
<property name="sizePolicy">
9181
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
@@ -98,7 +88,7 @@
9888
</property>
9989
</widget>
10090
</item>
101-
<item row="3" column="1">
91+
<item row="4" column="1">
10292
<widget class="QLineEdit" name="lePkiPathsKey">
10393
<property name="readOnly">
10494
<bool>true</bool>
@@ -108,7 +98,7 @@
10898
</property>
10999
</widget>
110100
</item>
111-
<item row="4" column="1">
101+
<item row="5" column="1">
112102
<widget class="QLineEdit" name="lePkiPathsKeyPass">
113103
<property name="echoMode">
114104
<enum>QLineEdit::Password</enum>
@@ -118,7 +108,7 @@
118108
</property>
119109
</widget>
120110
</item>
121-
<item row="5" column="1" colspan="2">
111+
<item row="6" column="1" colspan="3">
122112
<spacer name="verticalSpacer">
123113
<property name="orientation">
124114
<enum>Qt::Vertical</enum>
@@ -131,8 +121,8 @@
131121
</property>
132122
</spacer>
133123
</item>
134-
<item row="3" column="2">
135-
<widget class="QToolButton" name="btnPkiPathsKey">
124+
<item row="0" column="2">
125+
<widget class="QToolButton" name="btnPkiPathsCert">
136126
<property name="text">
137127
<string>…</string>
138128
</property>
@@ -142,6 +132,16 @@
142132
</widget>
143133
</item>
144134
<item row="4" column="2">
135+
<widget class="QToolButton" name="btnPkiPathsKey">
136+
<property name="text">
137+
<string>…</string>
138+
</property>
139+
<property name="popupMode">
140+
<enum>QToolButton::InstantPopup</enum>
141+
</property>
142+
</widget>
143+
</item>
144+
<item row="5" column="2">
145145
<widget class="QCheckBox" name="chkPkiPathsPassShow">
146146
<property name="sizePolicy">
147147
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
@@ -154,18 +154,57 @@
154154
</property>
155155
</widget>
156156
</item>
157-
<item row="0" column="2">
158-
<widget class="QToolButton" name="btnPkiPathsCert">
159-
<property name="text">
160-
<string>…</string>
161-
</property>
162-
<property name="popupMode">
163-
<enum>QToolButton::InstantPopup</enum>
164-
</property>
165-
</widget>
157+
<item row="2" column="2" rowspan="2">
158+
<layout class="QVBoxLayout" name="verticalLayout_2">
159+
<item>
160+
<widget class="QCheckBox" name="cbAddCas">
161+
<property name="toolTip">
162+
<string>Add bundle CAs to the connection</string>
163+
</property>
164+
<property name="text">
165+
<string>Add</string>
166+
</property>
167+
</widget>
168+
</item>
169+
<item>
170+
<widget class="QCheckBox" name="cbAddRootCa">
171+
<property name="toolTip">
172+
<string>Add also root (self-signed) CA</string>
173+
</property>
174+
<property name="text">
175+
<string>Root</string>
176+
</property>
177+
</widget>
178+
</item>
179+
<item>
180+
<spacer name="verticalSpacer_2">
181+
<property name="orientation">
182+
<enum>Qt::Vertical</enum>
183+
</property>
184+
<property name="sizeHint" stdset="0">
185+
<size>
186+
<width>20</width>
187+
<height>40</height>
188+
</size>
189+
</property>
190+
</spacer>
191+
</item>
192+
</layout>
166193
</item>
167194
</layout>
168195
</widget>
196+
<tabstops>
197+
<tabstop>lePkiPathsCert</tabstop>
198+
<tabstop>btnPkiPathsCert</tabstop>
199+
<tabstop>twCas</tabstop>
200+
<tabstop>cbAddCas</tabstop>
201+
<tabstop>cbAddRootCa</tabstop>
202+
<tabstop>lePkiPathsKey</tabstop>
203+
<tabstop>btnPkiPathsKey</tabstop>
204+
<tabstop>lePkiPathsKeyPass</tabstop>
205+
<tabstop>chkPkiPathsPassShow</tabstop>
206+
<tabstop>lePkiPathsMsg</tabstop>
207+
</tabstops>
169208
<resources/>
170209
<connections/>
171210
</ui>

‎src/auth/pkipaths/qgsauthpkipathsmethod.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,14 @@ bool QgsAuthPkiPathsMethod::updateNetworkRequest( QNetworkRequest &request, cons
105105
// this does not work due to the fact that QNAM overrides it in createRequest!
106106
if ( pkibundle->config().config( QStringLiteral( "addcas" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) )
107107
{
108-
sslConfig.setCaCertificates( pkibundle->caChain() );
108+
if ( pkibundle->config().config( QStringLiteral( "addrootca" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) )
109+
{
110+
sslConfig.setCaCertificates( pkibundle->caChain() );
111+
}
112+
else
113+
{
114+
sslConfig.setCaCertificates( QgsAuthCertUtils::casRemoveSelfSigned( pkibundle->caChain() ) );
115+
}
109116
}
110117
request.setSslConfiguration( sslConfig );
111118

0 commit comments

Comments
 (0)
Please sign in to comment.