mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-02 22:16:24 +00:00
Update cert generation for OpenSSL 4.0 compatibility
This commit is contained in:
@@ -74,7 +74,7 @@ int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int years) {
|
||||
EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits);
|
||||
|
||||
// pk must be initialized on input
|
||||
EVP_PKEY *pk = NULL;;
|
||||
EVP_PKEY *pk = NULL;
|
||||
EVP_PKEY_keygen(ctx, &pk);
|
||||
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
@@ -82,28 +82,17 @@ int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int years) {
|
||||
X509* cert = X509_new();
|
||||
X509_set_version(cert, 2);
|
||||
ASN1_INTEGER_set(X509_get_serialNumber(cert), serial);
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
X509_gmtime_adj(X509_get_notBefore(cert), 0);
|
||||
X509_gmtime_adj(X509_get_notAfter(cert), 60 * 60 * 24 * 365 * years);
|
||||
#else
|
||||
ASN1_TIME* before = ASN1_STRING_dup(X509_get0_notBefore(cert));
|
||||
ASN1_TIME* after = ASN1_STRING_dup(X509_get0_notAfter(cert));
|
||||
|
||||
X509_gmtime_adj(before, 0);
|
||||
X509_gmtime_adj(after, 60 * 60 * 24 * 365 * years);
|
||||
|
||||
X509_set1_notBefore(cert, before);
|
||||
X509_set1_notAfter(cert, after);
|
||||
|
||||
ASN1_STRING_free(before);
|
||||
ASN1_STRING_free(after);
|
||||
#endif
|
||||
X509_gmtime_adj(X509_getm_notBefore(cert), 0);
|
||||
X509_gmtime_adj(X509_getm_notAfter(cert), 60 * 60 * 24 * 365 * years);
|
||||
|
||||
X509_set_pubkey(cert, pk);
|
||||
|
||||
X509_NAME* name = X509_get_subject_name(cert);
|
||||
X509_NAME* name = X509_NAME_new();
|
||||
X509_NAME_add_entry_by_txt(name,"CN", MBSTRING_ASC, (unsigned char*)"NVIDIA GameStream Client", -1, -1, 0);
|
||||
X509_set_subject_name(cert, name);
|
||||
X509_set_issuer_name(cert, name);
|
||||
X509_NAME_free(name);
|
||||
|
||||
if (!X509_sign(cert, pk, EVP_sha256())) {
|
||||
goto err;
|
||||
|
||||
Reference in New Issue
Block a user