Avoid re-generating certs every time

Currently every test case in the TLS test suite generates the
certs fresh. This is a waste of time, since its parameters
don't change across test cases. Create certs once in main
method.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange
2013-08-05 17:08:17 +01:00
parent 236da82dae
commit 90811c5987
4 changed files with 442 additions and 387 deletions

View File

@@ -152,7 +152,8 @@ static void testTLSDerEncode(ASN1_TYPE src,
* TLS certificate code
*/
void
testTLSGenerateCert(struct testTLSCertReq *req)
testTLSGenerateCert(struct testTLSCertReq *req,
gnutls_x509_crt_t ca)
{
gnutls_x509_crt_t crt;
int err;
@@ -379,10 +380,10 @@ testTLSGenerateCert(struct testTLSCertReq *req)
/*
* If no 'cart' is set then we are self signing
* the cert. This is done for CA certs
* If no 'ca' is set then we are self signing
* the cert. This is done for the root CA certs
*/
if ((err = gnutls_x509_crt_sign(crt, req->cacrt ? req->cacrt : crt, privkey) < 0)) {
if ((err = gnutls_x509_crt_sign(crt, ca ? ca : crt, privkey) < 0)) {
VIR_WARN("Failed to sign certificate %s", gnutls_strerror(err));
abort();
}