eric6/WebBrowser/SiteInfo/SiteInfoDialog.py

changeset 7766
0af772bc14c4
parent 7759
51aa6c6b66f7
child 7768
6aec9032afad
--- a/eric6/WebBrowser/SiteInfo/SiteInfoDialog.py	Wed Oct 07 17:58:51 2020 +0200
+++ b/eric6/WebBrowser/SiteInfo/SiteInfoDialog.py	Wed Oct 07 19:14:36 2020 +0200
@@ -15,6 +15,11 @@
     QDialog, QTreeWidgetItem, QGraphicsScene, QMenu, QApplication,
     QGraphicsPixmapItem
 )
+try:
+    from PyQt5.QtNetwork import QSslCertificate     # __IGNORE_WARNING__
+    SSL = True
+except ImportError:
+    SSL = False
 
 from E5Gui import E5MessageBox, E5FileDialog
 
@@ -51,11 +56,15 @@
             0, UI.PixmapCache.getIcon("siteinfo-general"))
         self.tabWidget.setTabIcon(
             1, UI.PixmapCache.getIcon("siteinfo-media"))
+        if SSL:
+            self.tabWidget.setTabIcon(
+                2, UI.PixmapCache.getIcon("siteinfo-security"))
         
         self.__imageReply = None
         
         self.__baseUrl = browser.url()
         title = browser.title()
+        sslInfo = browser.page().getSslCertificateChain()
         
         #prepare background of image preview
         self.__imagePreviewStandardBackground = (
@@ -105,6 +114,13 @@
             "document.charset", WebBrowserPage.SafeJsWorld,
             lambda res: self.encodingLabel.setText(res))
         
+        # populate the Security tab
+        if sslInfo:
+            if SSL:
+                self.sslWidget.showCertificateChain(sslInfo)
+            self.tabWidget.setTabEnabled(2, SSL)
+            self.securityDetailsButton.setEnabled(SSL)
+        
         # populate Meta tags
         browser.page().runJavaScript(Scripts.getAllMetaAttributes(),
                                      WebBrowserPage.SafeJsWorld,
@@ -115,6 +131,16 @@
                                      WebBrowserPage.SafeJsWorld,
                                      self.__processImageTags)
         
+        self.tabWidget.setCurrentIndex(0)
+    
+    @pyqtSlot()
+    def on_securityDetailsButton_clicked(self):
+        """
+        Private slot to show security details.
+        """
+        self.tabWidget.setCurrentIndex(
+            self.tabWidget.indexOf(self.securityTab))
+    
     def __processImageTags(self, res):
         """
         Private method to process the image tags.

eric ide

mercurial