eric6/WebBrowser/Network/NetworkManager.py

changeset 7570
a7a5750aded4
parent 7565
928373562e36
child 7607
dd1054be15aa
child 7717
f32d7965a17e
equal deleted inserted replaced
7567:bb196e51827d 7570:a7a5750aded4
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
175 @param view reference to a view to be used as parent for the dialog 175 @param view reference to a view to be used as parent for the dialog
176 @type QWidget 176 @type QWidget
177 @return flag indicating to ignore this error 177 @return flag indicating to ignore this error
178 @rtype bool 178 @rtype bool
179 """ 179 """
180 if Preferences.getWebBrowser("AlwaysRejectFaultyCertificates"):
181 return False
182
180 self.__load() 183 self.__load()
181 184
182 host = error.url().host() 185 host = error.url().host()
183 186
184 self.__insecureHosts.add(host) 187 self.__insecureHosts.add(host)
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

eric ide

mercurial