Skip to content

Commit 1bc7fc3

Browse files
olszomalmtrojnar
authored andcommitted
Connect to CRL Distribution Points through the configured proxy when verifying
1 parent 42e9733 commit 1bc7fc3

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

NEWS.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
by using the "-verbose" option
1212
- added new command "extract-data" to extract a PKCS#7 data content to be signed
1313
- PKCS9_SEQUENCE_NUMBER authenticated attribute support
14-
- added the "-ignore-cdp" option to disable CRL Distribution Points
15-
online verification
14+
- added the "-ignore-cdp" option to disable CRL Distribution Points (CDP)
15+
online verification, inability to retrieve CRL from CDP is a critical error
16+
- modified the "-p" option to also connect to CRL Distribution Points
17+
through the configured proxy when verifying
1618

1719
### 2.7 (2023.09.19)
1820

osslsigncode.c

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,26 @@ static PKCS7 *pkcs7_get_sigfile(FILE_FORMAT_CTX *ctx);
227227

228228
static int blob_has_nl = 0;
229229

230+
static void print_proxy(char *proxy)
231+
{
232+
if (proxy) {
233+
printf ("Using configured proxy: %s\n", proxy);
234+
} else {
235+
char *http_proxy, *https_proxy;
236+
237+
http_proxy = getenv("http_proxy");
238+
if (!http_proxy)
239+
http_proxy = getenv("HTTP_PROXY");
240+
if (http_proxy && *http_proxy != '\0')
241+
printf ("Using environmental HTTP proxy: %s\n", http_proxy);
242+
https_proxy = getenv("https_proxy");
243+
if (!https_proxy)
244+
https_proxy = getenv("HTTPS_PROXY");
245+
if (https_proxy && *https_proxy != '\0')
246+
printf ("Using environmental HTTPS proxy: %s\n", https_proxy);
247+
}
248+
}
249+
230250
/*
231251
* Callback for writing received data
232252
*/
@@ -527,6 +547,7 @@ static BIO *bio_get_http(long *http_code, char *url, BIO *bout, char *proxy,
527547
if (!url) {
528548
return NULL; /* FAILED */
529549
}
550+
print_proxy(proxy);
530551
/* Start a libcurl easy session and set options for a curl easy handle */
531552
printf("Connecting to %s\n", url);
532553
curl = curl_easy_init();
@@ -1591,16 +1612,17 @@ static char *clrdp_url_get_x509(X509 *cert)
15911612
/*
15921613
* Get Certificate Revocation List from a CRL distribution point
15931614
* and write it into the X509_CRL structure.
1615+
* [in] proxy: proxy to getting CRL through
15941616
* [in] url: URL of the CRL distribution point server
15951617
* [returns] X509 Certificate Revocation List
15961618
*/
1597-
static X509_CRL *x509_crl_get(char *url)
1619+
static X509_CRL *x509_crl_get(char *proxy, char *url)
15981620
{
15991621
X509_CRL *crl;
16001622
BIO *bio;
16011623
long http_code = -1;
16021624

1603-
bio = bio_get_http(&http_code, url, NULL, NULL, 0, 1, 0);
1625+
bio = bio_get_http(&http_code, url, NULL, proxy, 0, 1, 0);
16041626
if (!bio) {
16051627
printf("Warning: Faild to get CRL from %s\n\n", url);
16061628
return NULL; /* FAILED */
@@ -1798,11 +1820,12 @@ static int verify_timestamp(FILE_FORMAT_CTX *ctx, PKCS7 *p7, CMS_ContentInfo *ti
17981820
printf("Ignored TSA's CRL distribution point: %s\n", url);
17991821
} else {
18001822
printf("TSA's CRL distribution point: %s\n", url);
1801-
crl = x509_crl_get(url);
1823+
crl = x509_crl_get(ctx->options->proxy, url);
18021824
}
18031825
OPENSSL_free(url);
18041826
if (!crl && !ctx->options->tsa_crlfile) {
18051827
printf("Use the \"-TSA-CRLfile\" option to add one or more Time-Stamp Authority CRLs in PEM format.\n");
1828+
goto out;
18061829
}
18071830
}
18081831
#endif /* ENABLE_CURL */
@@ -1923,7 +1946,7 @@ static int verify_authenticode(FILE_FORMAT_CTX *ctx, PKCS7 *p7, time_t time, X50
19231946
printf("Ignored CRL distribution point: %s\n", url);
19241947
} else {
19251948
printf("CRL distribution point: %s\n", url);
1926-
crl = x509_crl_get(url);
1949+
crl = x509_crl_get(ctx->options->proxy, url);
19271950
}
19281951
OPENSSL_free(url);
19291952
if (!crl && !ctx->options->crlfile) {
@@ -3037,6 +3060,7 @@ static void usage(const char *argv0, const char *cmd)
30373060
printf("%12s[ -CRLfile <infile> ]\n", "");
30383061
printf("%12s[ -TSA-CAfile <infile> ]\n", "");
30393062
printf("%12s[ -TSA-CRLfile <infile> ]\n", "");
3063+
printf("%12s[ -p <proxy> ]\n", "");
30403064
printf("%12s[ -index <index> ]\n", "");
30413065
printf("%12s[ -ignore-timestamp ]\n", "");
30423066
printf("%12s[ -ignore-cdp ]\n", "");
@@ -3090,7 +3114,7 @@ static void help_for(const char *argv0, const char *cmd)
30903114
const char *cmds_out[] = {"add", "attach-signature", "extract-signature",
30913115
"remove-signature", "sign", "extract-data", NULL};
30923116
#ifdef ENABLE_CURL
3093-
const char *cmds_p[] = {"add", "sign", NULL};
3117+
const char *cmds_p[] = {"add", "sign", "verify", NULL};
30943118
#endif /* ENABLE_CURL */
30953119
const char *cmds_pass[] = {"sign", NULL};
30963120
const char *cmds_pem[] = {"sign", "extract-data", "extract-signature", NULL};
@@ -3223,7 +3247,7 @@ static void help_for(const char *argv0, const char *cmd)
32233247
printf("%-24s= output file\n", "-out");
32243248
#ifdef ENABLE_CURL
32253249
if (on_list(cmd, cmds_p))
3226-
printf("%-24s= proxy to connect to the desired Time-Stamp Authority server\n", "-p");
3250+
printf("%-24s= proxy to connect to the desired Time-Stamp Authority server or CRL distribution point\n", "-p");
32273251
#endif /* ENABLE_CURL */
32283252
if (on_list(cmd, cmds_pass))
32293253
printf("%-24s= the private key password\n", "-pass");
@@ -4129,7 +4153,7 @@ static int main_configure(int argc, char **argv, GLOBAL_OPTIONS *options)
41294153
return 0; /* FAILED */
41304154
}
41314155
options->tsurl[options->ntsurl++] = *(++argv);
4132-
} else if ((cmd == CMD_SIGN || cmd == CMD_ADD) && !strcmp(*argv, "-p")) {
4156+
} else if ((cmd == CMD_SIGN || cmd == CMD_ADD || cmd == CMD_VERIFY) && !strcmp(*argv, "-p")) {
41334157
if (--argc < 1) {
41344158
usage(argv0, "all");
41354159
return 0; /* FAILED */

0 commit comments

Comments
 (0)