Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1422
  • Last Modified:

How to ignoreSslErrors with PyQt4 using QWebView

I have the following *very* simple web viewer.  I need it to show just a single internal site, however that site has a self-signed certificate which causes it not to load.  I know there's a way to use ignoreSslErrors with QNetworkManager, but I have been killing myself and cant figure out how to code it with what I have below.  Please help :P
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
from PyQt4 import QtGui
 
app = QApplication(sys.argv)
 
web = QWebView()
 
web.setWindowTitle("title")
screen = QtGui.QDesktopWidget().screenGeometry()
web.resize(screen.width()-10, screen.height()-60)
size = web.geometry()
web.move((screen.width()-8-size.width())/2, (screen.height()-60-size.height())/2)
web.load(QUrl("https://site-with-self-signed-certificate.com/"))
web.show()
 
sys.exit(app.exec_())

Open in new window

0
dipm
Asked:
dipm
1 Solution
 
ParanormasticCryptographic EngineerCommented:
Properly, you should have a ca_certs file that contains the root certificate you need.
http://docs.python.org/library/ssl.html

Here is a general code-example:
http://twistedmatrix.com/pipermail/twisted-python/2007-May/015357.html

It is a bad idea to not have a trusted roots file.  I understand it is just one page you are going to, but you do need to trust that you are actually talking to the server you think you are instead of a hacker misdirected site that looks the same.  Security should never be an afterthought.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now