mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
Fix import of private key with older gnutls
With older GNUTLS the gnutls_x509_privkey_import function is unable to import our private key. Instead we must use the alternative gnutls_x509_privkey_import_pkcs8() (as certtool does). * virnettlscontexttest.c: Fix import of private key with older gnutls. Also add missing newlines to key
This commit is contained in:
parent
567b8d69b9
commit
677258ab02
@ -59,21 +59,21 @@ extern const ASN1_ARRAY_TYPE pkix_asn1_tab[];
|
||||
gnutls_x509_privkey_t privkey;
|
||||
# define PRIVATE_KEY \
|
||||
"-----BEGIN PRIVATE KEY-----\n" \
|
||||
"MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBALVcr" \
|
||||
"BL40Tm6yq88FBhJNw1aaoCjmtg0l4dWQZ/e9Fimx4ARxFpT+ji4FE" \
|
||||
"Cgl9s/SGqC+1nvlkm9ViSo0j7MKDbnDB+VRHDvMAzQhA2X7e8M0n9" \
|
||||
"rPolUY2lIVC83q0BBaOBkCj2RSmT2xTEbbC2xLukSrg2WP/ihVOxc" \
|
||||
"kXRuyFtzAgMBAAECgYB7slBexDwXrtItAMIH6m/U+LUpNe0Xx48OL" \
|
||||
"IOn4a4whNgO/o84uIwygUK27ZGFZT0kAGAk8CdF9hA6ArcbQ62s1H" \
|
||||
"myxrUbF9/mrLsQw1NEqpuUk9Ay2Tx5U/wPx35S3W/X2AvR/ZpTnCn" \
|
||||
"2q/7ym9fyiSoj86drD7BTvmKXlOnOwQJBAPOFMp4mMa9NGpGuEssO" \
|
||||
"m3Uwbp6lhcP0cA9MK+iOmeANpoKWfBdk5O34VbmeXnGYWEkrnX+9J" \
|
||||
"bM4wVhnnBWtgBMCQQC+qAEmvwcfhauERKYznMVUVksyeuhxhCe7EK" \
|
||||
"mPh+U2+g0WwdKvGDgO0PPt1gq0ILEjspMDeMHVdTwkaVBo/uMhAkA" \
|
||||
"Z5SsZyCP2aTOPFDypXRdI4eqRcjaEPOUBq27r3uYb/jeboV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jjAJPyPiqFb3M8XXA26W\n" \
|
||||
"nz1KYGnqYKhLcBAkB7dt57n9xfrhDpuyVEv+Uv1D3VVAhZlsaZ5Pp\n" \
|
||||
"dcrhrkJn2sa/+O8OKvdrPSeeu/N5WwYhJf61+CPoenMp7IFci\n" \
|
||||
"-----END PRIVATE KEY-----\n"
|
||||
|
||||
@ -419,10 +419,17 @@ static gnutls_x509_privkey_t testTLSLoadKey(void)
|
||||
|
||||
if ((err = gnutls_x509_privkey_import(key, &data,
|
||||
GNUTLS_X509_FMT_PEM)) < 0) {
|
||||
VIR_WARN("Failed to init key %s", gnutls_strerror(err));
|
||||
if (err != GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR) {
|
||||
VIR_WARN("Failed to import key %s", gnutls_strerror(err));
|
||||
abort();
|
||||
}
|
||||
|
||||
if ((err = gnutls_x509_privkey_import_pkcs8(key, &data, GNUTLS_X509_FMT_PEM, NULL, 0)) < 0) {
|
||||
VIR_WARN("Failed to import PKCS8 key %s", gnutls_strerror(err));
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user