[cse] Do not save the certificate on disk

Store it on memory, and discard it as soon as no longer
needed.
This commit is contained in:
Tomaz Canabrava 2017-09-12 21:52:10 +02:00 committed by Roeland Jago Douma
parent d2992d92ba
commit ecb05020a9
No known key found for this signature in database
GPG key ID: F941078878347C0C

View file

@ -149,7 +149,12 @@ QString ClientSideEncryption::generateCSR(EVP_PKEY *keyPair)
int nVersion = 1;
X509_REQ *x509_req = NULL;
BIO *out = NULL;
auto out = BIO_new(BIO_s_mem());
QString output;
char data[80];
// auto out = BIO_new_file("/home/tcanabrava/.nextcloud-keys/request.pem","w");
// 2. set version of x509 req
x509_req = X509_REQ_new();
@ -179,12 +184,22 @@ QString ClientSideEncryption::generateCSR(EVP_PKEY *keyPair)
goto free_all;
}
out = BIO_new_file("/home/tcanabrava/.nextcloud-keys/request.pem","w");
ret = PEM_write_bio_X509_REQ(out, x509_req);
do {
ret = BIO_gets(out, data, 80);
output += data;
if (output.endsWith("-----END CERTIFICATE REQUEST-----"))
break;
} while (ret > 0 );
if (ret != 1) {
qCInfo(lcCse()) << "Error saving the csr file";
}
qCInfo(lcCse()) << "Returning the certificate";
qCInfo(lcCse()) << output;
free_all:
X509_REQ_free(x509_req);
BIO_free_all(out);