[cse] Correctly send the CSR

finally.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
Tomaz Canabrava 2017-09-13 20:52:55 +02:00 committed by Roeland Jago Douma
parent 307dfd195c
commit 090336c928
No known key found for this signature in database
GPG key ID: F941078878347C0C
2 changed files with 9 additions and 5 deletions

View file

@ -150,7 +150,7 @@ QString ClientSideEncryption::generateCSR(EVP_PKEY *keyPair)
X509_REQ *x509_req = nullptr;
auto out = BIO_new(BIO_s_mem());
QByteArray output("csr=\"");
QByteArray output;
char data[80];
SignPublicKeyApiJob *job = nullptr;
@ -186,10 +186,11 @@ QString ClientSideEncryption::generateCSR(EVP_PKEY *keyPair)
do {
ret = BIO_gets(out, data, 80);
output += data;
if (output.endsWith("-----END CERTIFICATE REQUEST-----"))
if (output.endsWith("-----END CERTIFICATE REQUEST-----")) {
output = output.trimmed();
break;
}
} while (ret > 0 );
output += "\"";
qCInfo(lcCse()) << "Returning the certificate";
qCInfo(lcCse()) << output;

View file

@ -30,7 +30,6 @@
#include <QPixmap>
#include <QJsonDocument>
#include <QJsonObject>
#include "networkjobs.h"
#include "account.h"
#include "owncloudpropagator.h"
@ -950,7 +949,9 @@ SignPublicKeyApiJob::SignPublicKeyApiJob(const AccountPtr& account, const QStrin
void SignPublicKeyApiJob::setCsr(const QByteArray& csr)
{
_csr.setData(csr);
QByteArray data = "csr=";
data += QUrl::toPercentEncoding(csr);
_csr.setData(data);
}
void SignPublicKeyApiJob::start()
@ -963,6 +964,7 @@ void SignPublicKeyApiJob::start()
};
url.setQueryItems(params);
qCInfo(lcSignPublicKeyApiJob) << "Sending the CSR" << _csr.data();
sendRequest("POST", url, req, &_csr);
AbstractNetworkJob::start();
}
@ -977,3 +979,4 @@ bool SignPublicKeyApiJob::finished()
}
} // namespace OCC