fix: invalid type conversion for OpenSSL 4.0.0
Since OpenSSL 4.0.0, X509_get_subject_name returns const X509_NAME
pointer, thus X509_NAME_add_entry_by_txt does not accept it anymore.
See /usr/include/openssl/x509.h.
Instead, explicitly operates it via mutable X509_NAME object.
It is safe operation without using X509_get_subject_name() because
subject name was not modified after cert = X509_new() assignment.
It will fix the following error.
error: invalid conversion from 'const X509_name_st*' to 'X509_NAME*' {aka 'X509_name
_st*'} [-fpermissive]
87 | X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, reinterpret_cast<const unsigned char *>("Deskflow"), -1, -1, 0);
| ^~~~
| |
| const X509_name_st*
Signed-off-by: Kentaro Hayashi <kenhys@xdump.org>
This commit is contained in:
parent
19a7dc622c
commit
fdb100649b
1 changed files with 6 additions and 1 deletions
|
|
@ -84,9 +84,14 @@ void generatePemSelfSignedCert(const QString &path, int keyLength)
|
|||
X509_gmtime_adj(X509_get_notAfter(cert), expirationDays * 24 * 3600);
|
||||
X509_set_pubkey(cert, privateKey);
|
||||
|
||||
auto *name = X509_get_subject_name(cert);
|
||||
auto *name = X509_NAME_new();
|
||||
if (!name) {
|
||||
throw std::runtime_error("could not allocate subject name");
|
||||
}
|
||||
X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, reinterpret_cast<const unsigned char *>("Deskflow"), -1, -1, 0);
|
||||
X509_set_subject_name(cert, name);
|
||||
X509_set_issuer_name(cert, name);
|
||||
X509_NAME_free(name);
|
||||
|
||||
X509_sign(cert, privateKey, EVP_sha256());
|
||||
const QFile file(path);
|
||||
|
|
|
|||
Loading…
Reference in a new issue