Skip to content
This repository
Browse code

Make ignoring SSL errors an option.

webkit_server takes an --ignore-ssl-errors argument.
  • Loading branch information...
commit f57b3a3d151e18da88ae61885b266c2bcf091f62 1 parent 9cfc6b1
Andrew Wason authored September 28, 2011 halogenandtoast committed October 14, 2011
3  src/Server.cpp
@@ -4,9 +4,10 @@
4 4
 
5 5
 #include <QTcpServer>
6 6
 
7  
-Server::Server(QObject *parent) : QObject(parent) {
  7
+Server::Server(QObject *parent, bool ignoreSslErrors) : QObject(parent) {
8 8
   m_tcp_server = new QTcpServer(this);
9 9
   m_page = new WebPage(this);
  10
+  m_page->setIgnoreSslErrors(ignoreSslErrors);
10 11
 }
11 12
 
12 13
 bool Server::start() {
2  src/Server.h
@@ -7,7 +7,7 @@ class Server : public QObject {
7 7
   Q_OBJECT
8 8
 
9 9
   public:
10  
-    Server(QObject *parent = 0);
  10
+    Server(QObject *parent, bool ignoreSslErrors);
11 11
     bool start();
12 12
     quint16 server_port() const;
13 13
 
12  src/WebPage.cpp
@@ -194,9 +194,19 @@ void WebPage::replyFinished(QNetworkReply *reply) {
194 194
 }
195 195
 
196 196
 void WebPage::ignoreSslErrors(QNetworkReply *reply, const QList<QSslError> &errors) {
197  
-  reply->ignoreSslErrors(errors);
  197
+  if (m_ignoreSslErrors)
  198
+    reply->ignoreSslErrors(errors);
198 199
 }
199 200
 
  201
+void WebPage::setIgnoreSslErrors(bool ignore) {
  202
+  m_ignoreSslErrors = ignore;
  203
+}
  204
+
  205
+bool WebPage::ignoreSslErrors() {
  206
+  return m_ignoreSslErrors;
  207
+}
  208
+
  209
+
200 210
 int WebPage::getLastStatus() {
201 211
   return m_lastStatus;
202 212
 }
3  src/WebPage.h
@@ -15,6 +15,8 @@ class WebPage : public QWebPage {
15 15
     void setCustomNetworkAccessManager();
16 16
     bool render(const QString &fileName);
17 17
     virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);
  18
+    void setIgnoreSslErrors(bool ignore);
  19
+    bool ignoreSslErrors();
18 20
 
19 21
   public slots:
20 22
     bool shouldInterruptJavaScript();
@@ -47,5 +49,6 @@ class WebPage : public QWebPage {
47 49
     void setUserStylesheet();
48 50
     int m_lastStatus;
49 51
     QString m_pageHeaders;
  52
+    bool m_ignoreSslErrors;
50 53
 };
51 54
 
7  src/main.cpp
@@ -18,10 +18,15 @@ int main(int argc, char **argv) {
18 18
   app.setOrganizationName("thoughtbot, inc");
19 19
   app.setOrganizationDomain("thoughtbot.com");
20 20
 
21  
-  Server server;
  21
+  QStringList args = app.arguments();
  22
+  bool ignoreSslErrors = args.contains("--ignore-ssl-errors");
  23
+
  24
+  Server server(0, ignoreSslErrors);
22 25
 
23 26
   if (server.start()) {
24 27
     std::cout << "Capybara-webkit server started, listening on port: " << server.server_port() << std::endl;
  28
+    if (ignoreSslErrors)
  29
+      std::cout << "Ignoring SSL errors" << std::endl;
25 30
     return app.exec();
26 31
   } else {
27 32
     std::cerr << "Couldn't start capybara-webkit server" << std::endl;

0 notes on commit f57b3a3

Please sign in to comment.
Something went wrong with that request. Please try again.