9 |
9 |
10 from PyQt6.QtCore import Qt, QUrl, QPoint |
10 from PyQt6.QtCore import Qt, QUrl, QPoint |
11 from PyQt6.QtWidgets import QMenu, QGridLayout, QLabel, QSizePolicy |
11 from PyQt6.QtWidgets import QMenu, QGridLayout, QLabel, QSizePolicy |
12 from PyQt6.QtNetwork import QSsl, QSslConfiguration, QSslCertificate |
12 from PyQt6.QtNetwork import QSsl, QSslConfiguration, QSslCertificate |
13 |
13 |
14 import UI.PixmapCache |
14 from eric7.EricGui import EricPixmapCache |
15 import Utilities |
15 from eric7 import Utilities |
16 |
16 |
17 |
17 |
18 class EricSslInfoWidget(QMenu): |
18 class EricSslInfoWidget(QMenu): |
19 """ |
19 """ |
20 Class implementing a widget to show SSL certificate infos. |
20 Class implementing a widget to show SSL certificate infos. |
59 |
59 |
60 label = QLabel(self) |
60 label = QLabel(self) |
61 label.setWordWrap(True) |
61 label.setWordWrap(True) |
62 if cert.isNull(): |
62 if cert.isNull(): |
63 label.setText(self.tr("Warning: this site is NOT carrying a certificate.")) |
63 label.setText(self.tr("Warning: this site is NOT carrying a certificate.")) |
64 imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityLow32")) |
64 imageLabel.setPixmap(EricPixmapCache.getPixmap("securityLow32")) |
65 else: |
65 else: |
66 valid = not cert.isBlacklisted() |
66 valid = not cert.isBlacklisted() |
67 if valid: |
67 if valid: |
68 txt = ", ".join(cert.issuerInfo(QSslCertificate.SubjectInfo.CommonName)) |
68 txt = ", ".join(cert.issuerInfo(QSslCertificate.SubjectInfo.CommonName)) |
69 label.setText( |
69 label.setText( |
70 self.tr( |
70 self.tr( |
71 "The certificate for this site is valid" |
71 "The certificate for this site is valid" |
72 " and has been verified by:\n{0}" |
72 " and has been verified by:\n{0}" |
73 ).format(Utilities.decodeString(txt)) |
73 ).format(Utilities.decodeString(txt)) |
74 ) |
74 ) |
75 imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityHigh32")) |
75 imageLabel.setPixmap(EricPixmapCache.getPixmap("securityHigh32")) |
76 else: |
76 else: |
77 label.setText(self.tr("The certificate for this site is NOT valid.")) |
77 label.setText(self.tr("The certificate for this site is NOT valid.")) |
78 imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityLow32")) |
78 imageLabel.setPixmap(EricPixmapCache.getPixmap("securityLow32")) |
79 layout.addWidget(label, rows, 1) |
79 layout.addWidget(label, rows, 1) |
80 rows += 1 |
80 rows += 1 |
81 |
81 |
82 label = QLabel(self) |
82 label = QLabel(self) |
83 label.setWordWrap(True) |
83 label.setWordWrap(True) |
126 layout.addWidget(label, rows, 1) |
126 layout.addWidget(label, rows, 1) |
127 |
127 |
128 proto = cipher.protocol() |
128 proto = cipher.protocol() |
129 if proto == QSsl.SslProtocol.TlsV1_0: |
129 if proto == QSsl.SslProtocol.TlsV1_0: |
130 sslVersion = "TLS v1.0" |
130 sslVersion = "TLS v1.0" |
131 imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityLow32")) |
131 imageLabel.setPixmap(EricPixmapCache.getPixmap("securityLow32")) |
132 elif proto == QSsl.SslProtocol.TlsV1_1: |
132 elif proto == QSsl.SslProtocol.TlsV1_1: |
133 sslVersion = "TLS v1.1" |
133 sslVersion = "TLS v1.1" |
134 imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityMedium32")) |
134 imageLabel.setPixmap(EricPixmapCache.getPixmap("securityMedium32")) |
135 elif proto == QSsl.SslProtocol.TlsV1_2: |
135 elif proto == QSsl.SslProtocol.TlsV1_2: |
136 sslVersion = "TLS v1.2" |
136 sslVersion = "TLS v1.2" |
137 imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityHigh32")) |
137 imageLabel.setPixmap(EricPixmapCache.getPixmap("securityHigh32")) |
138 elif proto == QSsl.SslProtocol.TlsV1_3: |
138 elif proto == QSsl.SslProtocol.TlsV1_3: |
139 sslVersion = "TLS v1.3" |
139 sslVersion = "TLS v1.3" |
140 imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityHigh32")) |
140 imageLabel.setPixmap(EricPixmapCache.getPixmap("securityHigh32")) |
141 elif proto == QSsl.SslProtocol.DtlsV1_0: |
141 elif proto == QSsl.SslProtocol.DtlsV1_0: |
142 sslVersion = "DTLS v1.0" |
142 sslVersion = "DTLS v1.0" |
143 imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityLow32")) |
143 imageLabel.setPixmap(EricPixmapCache.getPixmap("securityLow32")) |
144 elif proto == QSsl.SslProtocol.DtlsV1_2: |
144 elif proto == QSsl.SslProtocol.DtlsV1_2: |
145 sslVersion = "DTLS v1.2" |
145 sslVersion = "DTLS v1.2" |
146 imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityHigh32")) |
146 imageLabel.setPixmap(EricPixmapCache.getPixmap("securityHigh32")) |
147 else: |
147 else: |
148 sslVersion = self.tr("unknown") |
148 sslVersion = self.tr("unknown") |
149 imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityLow32")) |
149 imageLabel.setPixmap(EricPixmapCache.getPixmap("securityLow32")) |
150 rows += 1 |
150 rows += 1 |
151 |
151 |
152 label = QLabel(self) |
152 label = QLabel(self) |
153 label.setWordWrap(True) |
153 label.setWordWrap(True) |
154 label.setText(self.tr("It uses protocol: {0}").format(sslVersion)) |
154 label.setText(self.tr("It uses protocol: {0}").format(sslVersion)) |