Solved

How to ignoreSslErrors with PyQt4 using QWebView

Posted on 2009-05-06
2
1,346 Views
Last Modified: 2013-11-23
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
Comment
Question by:dipm
2 Comments
 
LVL 31

Accepted Solution

by:
Paranormastic earned 500 total points
ID: 24315838
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Strings in Python are the set of characters that, once defined, cannot be changed by any other method like replace. Even if we use the replace method it still does not modify the original string that we use, but just copies the string and then modif…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question