62 |
62 |
63 self.languagesChanged() |
63 self.languagesChanged() |
64 |
64 |
65 if SSL_AVAILABLE: |
65 if SSL_AVAILABLE: |
66 self.__sslErrorHandler = E5SslErrorHandler(self) |
66 self.__sslErrorHandler = E5SslErrorHandler(self) |
67 self.sslErrors.connect(self.__sslErrorHandler.sslErrorsReplySlot) |
67 self.sslErrors.connect(self.__sslErrorHandlingSlot) |
68 |
68 |
69 self.__temporarilyIgnoredSslErrors = {} |
69 self.__temporarilyIgnoredSslErrors = {} |
70 self.__permanentlyIgnoredSslErrors = {} |
70 self.__permanentlyIgnoredSslErrors = {} |
71 # dictionaries of permanently and temporarily ignored SSL errors |
71 # dictionaries of permanently and temporarily ignored SSL errors |
72 |
72 |
198 title = self.tr("SSL Certificate Error") |
201 title = self.tr("SSL Certificate Error") |
199 msgBox = E5MessageBox.E5MessageBox( |
202 msgBox = E5MessageBox.E5MessageBox( |
200 E5MessageBox.Warning, |
203 E5MessageBox.Warning, |
201 title, |
204 title, |
202 self.tr("""<b>{0}</b>""" |
205 self.tr("""<b>{0}</b>""" |
203 """<p>The page you are trying to access has errors""" |
206 """<p>The host <b>{1}</b> you are trying to access has""" |
204 """ in the SSL certificate.</p>""" |
207 """ errors in the SSL certificate.</p>""" |
205 """<ul><li>{1}</li></ul>""" |
208 """<ul><li>{2}</li></ul>""" |
206 """<p>Would you like to make an exception?</p>""") |
209 """<p>Would you like to make an exception?</p>""") |
207 .format(title, error.errorDescription()), |
210 .format(title, host, error.errorDescription()), |
208 modal=True, parent=view) |
211 modal=True, parent=view) |
209 permButton = msgBox.addButton(self.tr("&Permanent accept"), |
212 permButton = msgBox.addButton(self.tr("&Permanent accept"), |
210 E5MessageBox.AcceptRole) |
213 E5MessageBox.AcceptRole) |
211 tempButton = msgBox.addButton(self.tr("&Temporary accept"), |
214 tempButton = msgBox.addButton(self.tr("&Temporary accept"), |
212 E5MessageBox.AcceptRole) |
215 E5MessageBox.AcceptRole) |
224 self.__temporarilyIgnoredSslErrors[host].append(error.error()) |
227 self.__temporarilyIgnoredSslErrors[host].append(error.error()) |
225 return True |
228 return True |
226 else: |
229 else: |
227 return False |
230 return False |
228 |
231 |
|
232 def __sslErrorHandlingSlot(self, reply, errors): |
|
233 """ |
|
234 Private slot to handle SSL errors for a network reply. |
|
235 |
|
236 @param reply reference to the reply object |
|
237 @type QNetworkReply |
|
238 @param errors list of SSL errors |
|
239 @type list of QSslError |
|
240 """ |
|
241 if Preferences.getWebBrowser("AlwaysRejectFaultyCertificates"): |
|
242 return |
|
243 |
|
244 self.__load() |
|
245 |
|
246 host = reply.url().host() |
|
247 if ( |
|
248 host in self.__permanentlyIgnoredSslErrors or |
|
249 host in self.__temporarilyIgnoredSslErrors |
|
250 ): |
|
251 reply.ignoreSslErrors() |
|
252 else: |
|
253 self.__sslErrorHandler.sslErrorsReply(reply, errors) |
|
254 |
229 def isInsecureHost(self, host): |
255 def isInsecureHost(self, host): |
230 """ |
256 """ |
231 Public method to check a host against the list of insecure hosts. |
257 Public method to check a host against the list of insecure hosts. |
232 |
258 |
|
259 @param host name of the host to be checked |
|
260 @type str |
233 @return flag indicating an insecure host |
261 @return flag indicating an insecure host |
234 @rtype bool |
262 @rtype bool |
235 """ |
263 """ |
236 return host in self.__insecureHosts |
264 return host in self.__insecureHosts |
237 |
265 |