Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QWebEngineView Adding certificate verification



  • Hi!
    I wont open url in QWebEngineView, but i get error:

    [103262:103307:0603/125326.532299:ERROR:cert_verify_proc_nss.cc(977)] CERT_PKIXVerifyCert for 10.0.102.112 failed err=-8172
    InsecureRequestWarning: Unverified HTTPS request is being made to host '10.0.102.112'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
      warnings.warn(
    

    How I can open this url?



  • The Simple Browser Example has a section describing how to manage ssl errors.



  • it is work

    import sys
    
    
    from PyQt5.QtCore import QUrl
    from PyQt5.QtWidgets import QApplication
    from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage, QWebEngineCertificateError
    # from PyQt5.QtNetwork import QSslSocket
    
    
    
    class WebEnginePage(QWebEnginePage):
        def __init__(self, parent=None):
            super(QWebEnginePage, self).__init__()
        def certificateError(self, error):
    
            # error.ignoreCertificateError()
            # return True
            return error.isOverridable()
    
    
    def main(args):
        app = QApplication(args)
        webview = QWebEngineView()
        page = WebEnginePage()
        webview.setPage(page)
        webview.load(QUrl("https://www.us.army.mil/"))
        webview.show()
        sys.exit(app.exec_())
    
    
    if __name__ == "__main__":
        main(sys.argv)
    

Log in to reply