|
Lines 1-129
Link Here
|
| 1 |
diff --git a/AUTHORS ../wkhtmltopdf-0.12.4/AUTHORS |
|
|
| 2 |
index 62f43f4..1067b9b 100644 |
| 3 |
--- a/AUTHORS |
| 4 |
+++ ../wkhtmltopdf-0.12.4/AUTHORS |
| 5 |
@@ -38,3 +38,4 @@ Mehdi Abbad |
| 6 |
Lyes Amazouz |
| 7 |
Pascal Bach |
| 8 |
Mário Silva |
| 9 |
+Jason Smith <JasonParallel@gmail.com> |
| 10 |
diff --git a/include/wkhtmltox/loadsettings.hh ../wkhtmltopdf-0.12.4/include/wkhtmltox/loadsettings.hh |
| 11 |
index 5b9565f..3b9c765 100644 |
| 12 |
--- a/include/wkhtmltox/loadsettings.hh |
| 13 |
+++ ../wkhtmltopdf-0.12.4/include/wkhtmltox/loadsettings.hh |
| 14 |
@@ -67,6 +67,15 @@ struct DLL_PUBLIC LoadPage { |
| 15 |
//! Password used for http auth login |
| 16 |
QString password; |
| 17 |
|
| 18 |
+ //! Path to the ssl client cert private key in OpenSSL PEM format |
| 19 |
+ QString clientSslKeyPath; |
| 20 |
+ |
| 21 |
+ //! Password to ssl client cert private key |
| 22 |
+ QString clientSslKeyPassword; |
| 23 |
+ |
| 24 |
+ //! Path to the ssl client cert public key in OpenSSL PEM format, optionally followed by intermediate ca and trusted certs |
| 25 |
+ QString clientSslCrtPath; |
| 26 |
+ |
| 27 |
//! How many milliseconds should we wait for a Javascript redirect |
| 28 |
int jsdelay; |
| 29 |
|
| 30 |
diff --git a/src/lib/loadsettings.hh ../wkhtmltopdf-0.12.4/src/lib/loadsettings.hh |
| 31 |
index 20a5da2..bdd2739 100644 |
| 32 |
--- a/src/lib/loadsettings.hh |
| 33 |
+++ ../wkhtmltopdf-0.12.4/src/lib/loadsettings.hh |
| 34 |
@@ -70,6 +70,15 @@ struct DLL_PUBLIC LoadPage { |
| 35 |
//! Password used for http auth login |
| 36 |
QString password; |
| 37 |
|
| 38 |
+ //! Path to the ssl client cert private key in OpenSSL PEM format |
| 39 |
+ QString clientSslKeyPath; |
| 40 |
+ |
| 41 |
+ //! Password to ssl client cert private key |
| 42 |
+ QString clientSslKeyPassword; |
| 43 |
+ |
| 44 |
+ //! Path to the ssl client cert public key in OpenSSL PEM format, optionally followed by intermediate ca and trusted certs |
| 45 |
+ QString clientSslCrtPath; |
| 46 |
+ |
| 47 |
//! How many milliseconds should we wait for a Javascript redirect |
| 48 |
int jsdelay; |
| 49 |
|
| 50 |
diff --git a/src/lib/multipageloader.cc ../wkhtmltopdf-0.12.4/src/lib/multipageloader.cc |
| 51 |
index 7e61485..841dd6e 100644 |
| 52 |
--- a/src/lib/multipageloader.cc |
| 53 |
+++ ../wkhtmltopdf-0.12.4/src/lib/multipageloader.cc |
| 54 |
@@ -26,6 +26,13 @@ |
| 55 |
#include <QNetworkDiskCache> |
| 56 |
#include <QTimer> |
| 57 |
#include <QUuid> |
| 58 |
+#include <QList> |
| 59 |
+#include <QByteArray> |
| 60 |
+#if (QT_VERSION >= 0x050000 && !defined QT_NO_SSL) || !defined QT_NO_OPENSSL |
| 61 |
+#include <QSslCertificate> |
| 62 |
+#include <QSslKey> |
| 63 |
+#include <QSslConfiguration> |
| 64 |
+#endif |
| 65 |
#if QT_VERSION >= 0x050000 |
| 66 |
#include <QUrlQuery> |
| 67 |
#endif |
| 68 |
@@ -104,6 +111,33 @@ QNetworkReply * MyNetworkAccessManager::createRequest(Operation op, const QNetwo |
| 69 |
foreach (const HT & j, settings.customHeaders) |
| 70 |
r3.setRawHeader(j.first.toLatin1(), j.second.toLatin1()); |
| 71 |
} |
| 72 |
+ |
| 73 |
+ #if (QT_VERSION >= 0x050000 && !defined QT_NO_SSL) || !defined QT_NO_OPENSSL |
| 74 |
+ if(!settings.clientSslKeyPath.isEmpty() && !settings.clientSslKeyPassword.isEmpty() |
| 75 |
+ && !settings.clientSslCrtPath.isEmpty()){ |
| 76 |
+ bool success = true; |
| 77 |
+ QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration(); |
| 78 |
+ |
| 79 |
+ QFile keyFile(settings.clientSslKeyPath); |
| 80 |
+ if(keyFile.open(QFile::ReadOnly)){ |
| 81 |
+ QSslKey key(&keyFile, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, settings.clientSslKeyPassword.toUtf8()); |
| 82 |
+ sslConfig.setPrivateKey(key); |
| 83 |
+ keyFile.close(); |
| 84 |
+ |
| 85 |
+ QList<QSslCertificate> chainCerts = |
| 86 |
+ QSslCertificate::fromPath(settings.clientSslCrtPath.toLatin1(), QSsl::Pem, QRegExp::FixedString); |
| 87 |
+ QList<QSslCertificate> cas = sslConfig.caCertificates(); |
| 88 |
+ cas.append(chainCerts); |
| 89 |
+ if(!chainCerts.isEmpty()){ |
| 90 |
+ sslConfig.setLocalCertificate(chainCerts.first()); |
| 91 |
+ sslConfig.setCaCertificates(cas); |
| 92 |
+ |
| 93 |
+ r3.setSslConfiguration(sslConfig); |
| 94 |
+ } |
| 95 |
+ } |
| 96 |
+ } |
| 97 |
+ #endif |
| 98 |
+ |
| 99 |
return QNetworkAccessManager::createRequest(op, r3, outgoingData); |
| 100 |
} |
| 101 |
|
| 102 |
diff --git a/src/lib/reflect.cc ../wkhtmltopdf-0.12.4/src/lib/reflect.cc |
| 103 |
index 32fc819..46e884c 100644 |
| 104 |
--- a/src/lib/reflect.cc |
| 105 |
+++ ../wkhtmltopdf-0.12.4/src/lib/reflect.cc |
| 106 |
@@ -57,6 +57,9 @@ ReflectImpl<LoadGlobal>::ReflectImpl(LoadGlobal & c) { |
| 107 |
ReflectImpl<LoadPage>::ReflectImpl(LoadPage & c) { |
| 108 |
WKHTMLTOPDF_REFLECT(username); |
| 109 |
WKHTMLTOPDF_REFLECT(password); |
| 110 |
+ WKHTMLTOPDF_REFLECT(clientSslKeyPath); |
| 111 |
+ WKHTMLTOPDF_REFLECT(clientSslKeyPassword); |
| 112 |
+ WKHTMLTOPDF_REFLECT(clientSslCrtPath); |
| 113 |
WKHTMLTOPDF_REFLECT(jsdelay); |
| 114 |
WKHTMLTOPDF_REFLECT(windowStatus); |
| 115 |
WKHTMLTOPDF_REFLECT(zoomFactor); |
| 116 |
diff --git a/src/shared/commonarguments.cc ../wkhtmltopdf-0.12.4/src/shared/commonarguments.cc |
| 117 |
index 3d45aaf..812f7b8 100644 |
| 118 |
--- a/src/shared/commonarguments.cc |
| 119 |
+++ ../wkhtmltopdf-0.12.4/src/shared/commonarguments.cc |
| 120 |
@@ -206,6 +206,9 @@ void CommandLineParserBase::addPageLoadArgs(LoadPage & s) { |
| 121 |
addarg("bypass-proxy-for", 0, "Bypass proxy for host (repeatable)", new StringListSetter(s.bypassProxyForHosts, "value")); |
| 122 |
addarg("username",0,"HTTP Authentication username", new QStrSetter(s.username, "username")); |
| 123 |
addarg("password",0,"HTTP Authentication password", new QStrSetter(s.password, "password")); |
| 124 |
+ addarg("ssl-key-path",0,"Path to ssl client cert private key in OpenSSL PEM format", new QStrSetter(s.clientSslKeyPath, "path")); |
| 125 |
+ addarg("ssl-key-password",0,"Password to ssl client cert private key", new QStrSetter(s.clientSslKeyPassword, "password")); |
| 126 |
+ addarg("ssl-crt-path",0,"Path to the ssl client cert public key in OpenSSL PEM format, optionally followed by intermediate ca and trusted certs", new QStrSetter(s.clientSslCrtPath, "path")); |
| 127 |
addarg("load-error-handling", 0, "Specify how to handle pages that fail to load: abort, ignore or skip", new LoadErrorHandlingSetting(s.loadErrorHandling, "handler")); |
| 128 |
addarg("load-media-error-handling", 0, "Specify how to handle media files that fail to load: abort, ignore or skip", new LoadErrorHandlingSetting(s.mediaLoadErrorHandling, "handler")); |
| 129 |
addarg("custom-header",0,"Set an additional HTTP header (repeatable)", new MapSetter<>(s.customHeaders, "name", "value")); |