Closed brechtsanders closed 2 years ago
OpenSSL 3 is supported.
osslsigncode.exe --version
osslsigncode 2.4, using:
OpenSSL 3.0.5 5 Jul 2022 (Library: OpenSSL 3.0.5 5 Jul 2022)
libcurl/7.84.0-DEV Schannel zlib/1.2.12
My output looks like this:
[1/5] Building C object CMakeFiles/osslsigncode.dir/osslsigncode.c.obj
FAILED: CMakeFiles/osslsigncode.dir/osslsigncode.c.obj
D:\Prog\winlibs64-11.3.0msvcrt\mingw64\bin\gcc.exe -DENABLE_CURL=1 -DHAVE_CONFIG_H=1 -IR:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/build_win -O3 -DNDEBUG -fPIE -std=gnu11 -MD -MT CMakeFiles/osslsigncode.dir/osslsigncode.c.obj -MF CMakeFiles\osslsigncode.dir\osslsigncode.c.obj.d -o CMakeFiles/osslsigncode.dir/osslsigncode.c.obj -c R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c
In file included from d:\prog\winlibs64-11.3.0msvcrt\mingw64\x86_64-w64-mingw32\include\windows.h:95,
from d:\prog\winlibs64-11.3.0msvcrt\mingw64\x86_64-w64-mingw32\include\winsock2.h:23,
from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/curl/system.h:408,
from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/curl/curl.h:37,
from R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:125:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:734:35: error: expected declaration specifiers or '...' before '(' token
734 | static int pkcs7_add_signing_time(PKCS7_SIGNER_INFO *si, time_t time)
| ^~~~~~~~~~~~~~~~~
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c: In function 'encode_rfc3161_request':
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:851:28: error: 'si' undeclared (first use in this function); did you mean 'sig'?
851 | PKCS7_SIGNER_INFO *si;
| ^~
| sig
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:851:28: note: each undeclared identifier is reported only once for each function it appears in
In file included from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/openssl/x509.h:480,
from R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:104:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:862:14: error: expected expression before ')' token
862 | si = sk_PKCS7_SIGNER_INFO_value(signer_info, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c: In function 'encode_authenticode_request':
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:902:28: error: 'si' undeclared (first use in this function); did you mean 'sig'?
902 | PKCS7_SIGNER_INFO *si;
| ^~
| sig
In file included from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/openssl/x509.h:480,
from R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:104:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:911:14: error: expected expression before ')' token
911 | si = sk_PKCS7_SIGNER_INFO_value(signer_info, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c: In function 'decode_rfc3161_response':
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:943:28: error: 'si' undeclared (first use in this function); did you mean 'sig'?
943 | PKCS7_SIGNER_INFO *si;
| ^~
| sig
In file included from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/openssl/x509.h:480,
from R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:104:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:952:14: error: expected expression before ')' token
952 | si = sk_PKCS7_SIGNER_INFO_value(signer_info, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c: In function 'decode_authenticode_response':
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:1000:28: error: 'info' undeclared (first use in this function)
1000 | PKCS7_SIGNER_INFO *info, *si;
| ^~~~
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:1000:35: error: 'si' undeclared (first use in this function); did you mean 'sig'?
1000 | PKCS7_SIGNER_INFO *info, *si;
| ^~
| sig
In file included from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/openssl/x509.h:480,
from R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:104:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:1022:16: error: expected expression before ')' token
1022 | info = sk_PKCS7_SIGNER_INFO_value(signer_info, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:1044:14: error: expected expression before ')' token
1044 | si = sk_PKCS7_SIGNER_INFO_value(signer_info, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from d:\prog\winlibs64-11.3.0msvcrt\mingw64\x86_64-w64-mingw32\include\windows.h:95,
from d:\prog\winlibs64-11.3.0msvcrt\mingw64\x86_64-w64-mingw32\include\winsock2.h:23,
from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/curl/system.h:408,
from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/curl/curl.h:37,
from R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:125:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c: At top level:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:2029:27: error: expected declaration specifiers or '...' before '(' token
2029 | static time_t si_get_time(PKCS7_SIGNER_INFO *si)
| ^~~~~~~~~~~~~~~~~
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c: In function 'cms_print_timestamp':
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:2173:20: error: 'issuer' undeclared (first use in this function); did you mean 'iswupper'?
2173 | X509_NAME *issuer = NULL;
| ^~~~~~
| iswupper
In file included from d:\prog\winlibs64-11.3.0msvcrt\mingw64\x86_64-w64-mingw32\include\windows.h:95,
from d:\prog\winlibs64-11.3.0msvcrt\mingw64\x86_64-w64-mingw32\include\winsock2.h:23,
from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/curl/system.h:408,
from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/curl/curl.h:37,
from R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:125:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c: At top level:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:2204:68: error: expected declaration specifiers or '...' before '(' token
2204 | static CMS_ContentInfo *cms_get_timestamp(PKCS7_SIGNED *p7_signed, PKCS7_SIGNER_INFO *countersignature)
| ^~~~~~~~~~~~~~~~~
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c: In function 'get_unsigned_attributes':
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:2416:44: error: 'countersi' undeclared (first use in this function)
2416 | PKCS7_SIGNER_INFO *countersi;
| ^~~~~~~~~
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:2429:32: warning: implicit declaration of function 'si_get_time'; did you mean 'cms_get_time'? [-Wimplicit-function-declaration]
2429 | time = si_get_time(countersi);
| ^~~~~~~~~~~
| cms_get_time
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:2431:45: warning: implicit declaration of function 'cms_get_timestamp'; did you mean 'cms_print_timestamp'? [-Wimplicit-function-declaration]
2431 | timestamp = cms_get_timestamp(p7->d.sign, countersi);
| ^~~~~~~~~~~~~~~~~
| cms_print_timestamp
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c: In function 'append_signature_list':
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:2491:28: error: 'si' undeclared (first use in this function)
2491 | PKCS7_SIGNER_INFO *si;
| ^~
In file included from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/openssl/x509.h:480,
from R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:104:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:2497:14: error: expected expression before ')' token
2497 | si = sk_PKCS7_SIGNER_INFO_value(signer_info, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from d:\prog\winlibs64-11.3.0msvcrt\mingw64\x86_64-w64-mingw32\include\windows.h:95,
from d:\prog\winlibs64-11.3.0msvcrt\mingw64\x86_64-w64-mingw32\include\winsock2.h:23,
from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/curl/system.h:408,
from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/curl/curl.h:37,
from R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:125:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c: At top level:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:2534:51: error: expected declaration specifiers or '...' before '(' token
2534 | static int TST_verify(CMS_ContentInfo *timestamp, PKCS7_SIGNER_INFO *si) | ^~~~~~~~~~~~~~~~~
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c: In function 'pkcs7_set_nested_signature':
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:2624:28: error: 'si' undeclared (first use in this function)
2624 | PKCS7_SIGNER_INFO *si;
| ^~
In file included from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/openssl/x509.h:480,
from R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:104:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:2629:14: error: expected expression before ')' token
2629 | si = sk_PKCS7_SIGNER_INFO_value(signer_info, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:2638:9: warning: implicit declaration of function 'pkcs7_add_signing_time'; did you mean 'PKCS7_add_signature'? [-Wimplicit-function-declaration]
2638 | pkcs7_add_signing_time(si, time);
| ^~~~~~~~~~~~~~~~~~~~~~
| PKCS7_add_signature
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c: In function 'verify_timestamp':
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:2731:28: error: 'si' undeclared (first use in this function)
2731 | PKCS7_SIGNER_INFO *si;
| ^~
In file included from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/openssl/x509.h:480,
from R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:104:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:2798:14: error: expected expression before ')' token
2798 | si = sk_PKCS7_SIGNER_INFO_value(signer_info, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:2801:14: warning: implicit declaration of function 'TST_verify'; did you mean 'CMS_verify'? [-Wimplicit-function-declaration]
2801 | if (!TST_verify(signature->timestamp, si))
| ^~~~~~~~~~
| CMS_verify
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c: In function 'cat_verify_header':
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:4174:28: error: 'si' undeclared (first use in this function)
4174 | PKCS7_SIGNER_INFO *si;
| ^~
In file included from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/openssl/x509.h:480,
from R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:104:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:4188:14: error: expected expression before ')' token
4188 | si = sk_PKCS7_SIGNER_INFO_value(signer_info, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from d:\prog\winlibs64-11.3.0msvcrt\mingw64\x86_64-w64-mingw32\include\windows.h:95,
from d:\prog\winlibs64-11.3.0msvcrt\mingw64\x86_64-w64-mingw32\include\winsock2.h:23,
from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/curl/system.h:408,
from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/curl/curl.h:37,
from R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:125:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c: At top level:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:4372:30: error: expected declaration specifiers or '...' before '(' token
4372 | static void add_jp_attribute(PKCS7_SIGNER_INFO *si, int jp)
| ^~~~~~~~~~~~~~~~~
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:4396:34: error: expected declaration specifiers or '...' before '(' token
4396 | static int add_purpose_attribute(PKCS7_SIGNER_INFO *si, int comm)
| ^~~~~~~~~~~~~~~~~
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:4410:31: error: expected declaration specifiers or '...' before '(' token
4410 | static int add_opus_attribute(PKCS7_SIGNER_INFO *si, char *desc, char *url)
| ^~~~~~~~~~~~~~~~~
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c: In function 'create_new_signature':
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:4437:28: error: 'si' undeclared (first use in this function); did you mean 'sig'?
4437 | PKCS7_SIGNER_INFO *si = NULL;
| ^~
| sig
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:4477:17: warning: implicit declaration of function 'add_jp_attribute' [-Wimplicit-function-declaration]
4477 | add_jp_attribute(si, options->jp);
| ^~~~~~~~~~~~~~~~
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:4479:14: warning: implicit declaration of function 'add_purpose_attribute' [-Wimplicit-function-declaration]
4479 | if (!add_purpose_attribute(si, options->comm))
| ^~~~~~~~~~~~~~~~~~~~~
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:4483:26: warning: implicit declaration of function 'add_opus_attribute'; did you mean '__has_attribute'? [-Wimplicit-function-declaration]
4483 | !add_opus_attribute(si, options->desc, options->url)) {
| ^~~~~~~~~~~~~~~~~~
| __has_attribute
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c: In function 'add_unauthenticated_blob':
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:4516:28: error: 'si' undeclared (first use in this function); did you mean 'sig'?
4516 | PKCS7_SIGNER_INFO *si;
| ^~
| sig
In file included from D:\Prog\winlibs64-11.3.0msvcrt\custombuilt\include/openssl/x509.h:480,
from R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:104:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:4527:14: error: expected expression before ')' token
4527 | si = sk_PKCS7_SIGNER_INFO_value(sig->d.sign->signer_info, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
Found this in openssl/types.h
:
# ifdef _WIN32
# undef X509_NAME
# undef X509_EXTENSIONS
# undef PKCS7_ISSUER_AND_SERIAL
# undef PKCS7_SIGNER_INFO
# undef OCSP_REQUEST
# undef OCSP_RESPONSE
# endif
However openssl/pkcs7.h
defines PKCS7_SIGNER_INFO
like this:
typedef struct pkcs7_signer_info_st {
ASN1_INTEGER *version; /* version 1 */
PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;
X509_ALGOR *digest_alg;
STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */
X509_ALGOR *digest_enc_alg;
ASN1_OCTET_STRING *enc_digest;
STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */
/* The private key to sign with */
EVP_PKEY *pkey;
const PKCS7_CTX *ctx;
} PKCS7_SIGNER_INFO;
The error goes away if I insert
#undef PKCS7_SIGNER_INFO
#define PKCS7_SIGNER_INFO struct pkcs7_signer_info_st
after:
#include <curl/curl.h>
So it looks like libcurl is somehow (re)defining it.
Then I get another error:
R:/winlibs64-11.3.0msvcrt/osslsigncode-2.4/osslsigncode.c:2175:20: error: 'issuer' undeclared (first use in this function); did you mean 'iswupper'?
2175 | X509_NAME *issuer = NULL;
| ^~~~~~
| iswupper
So it looks like X509_NAME is having similar issues
These are also fixed by adding these lines in the same place:
#undef X509_NAME
#define X509_NAME struct X509_name_st
Would it be an option to use use struct pkcs7_signer_info_st
/ struct X509_name_st
instead of PKCS7_SIGNER_INFO
/ X509_NAME
?
Which version of curl
do you use? Can you try to update your curl
?
libcurl 7.84.0, this is the most recent version. In fact all my dependencies are the most recent version built from source.
After my workaround I still had to remove the -Wl,-z,
lines from cmake/SetCompilerFlags.cmake
as this doesn't work with GCC. Then I was able to build everything. Maybe these line should be set conditionally for LLVM only.
FYI: my build script for MinGW-w64 can be found here: https://github.com/brechtsanders/winlibs_recipes/blob/main/recipes/osslsigncode.winlib
Interesting. Apparently, I need to add MinGW-w64 to the CI, because I couldn't reproduce these issues on any other platform.
Do you want me to make a PR with an #ifdef
to do the workaround only for MinGW-w64?
Please let me reproduce it first.
Any chance OpenSSL 3 will be support? The latest OpenSSL version is 3.0.5. Or else GnuTLS as an alternative to OpenSSL?