Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate and expose nextUpdate field in OCSP response #1694

Merged
merged 2 commits into from
Mar 10, 2024

Conversation

ElvinEfendi
Copy link
Contributor

@ElvinEfendi ElvinEfendi commented Apr 18, 2020

I hereby granted the copyright of the changes in this pull request
to the authors of this lua-nginx-module project.

Required by openresty/lua-resty-core#296

This is an alternative solution to #1041. I like the approach in this PR better because it adds minimal amount of code and it makes sense for validation API to return this data.

The code has been fork lifted from Nginx source and adjusted here.

In addition to exposing nextUpdate field, this way we will also be validating nextUpdate field.

@ElvinEfendi ElvinEfendi marked this pull request as ready for review April 18, 2020 14:47
@ElvinEfendi
Copy link
Contributor Author

For tests see openresty/lua-resty-core#296 (comment)


static time_t ngx_http_lua_ssl_stapling_time(ASN1_GENERALIZEDTIME *asn1time);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please always use std type names like long in our ABI functions to avoid any potential compatibility issues.

@@ -383,6 +384,16 @@ ngx_http_lua_ffi_ssl_validate_ocsp_response(const u_char *resp,
goto error;
}

if (nextupdate) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we explicitly test if nextupdate is equal to zero instead of testing it as a boolean value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a double pointer to ASN1_GENERALIZEDTIME type, I don't know if we can easily compare it to zero. Also NGINX follows this approach: /~https://github.com/nginx/nginx/blob/7547581bbcb7b737710f9141260d822a08685b83/src/event/ngx_event_openssl_stapling.c#L2392

@@ -437,6 +448,39 @@ ngx_http_lua_ssl_empty_status_callback(ngx_ssl_conn_t *ssl_conn, void *data)
{
return SSL_TLSEXT_ERR_OK;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use 2 blank lines to separate function definitions.


/* fake weekday prepended to match C asctime() format */

BIO_write(bio, "Tue ", sizeof("Tue ") - 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we check the return values of BIO_write() for any errors here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the input is hardcoded, there's probably not much value in testing that. But if you feel strongly about it I can check the return value too.

@zhuizhuhaomeng
Copy link
Contributor

@ElvinEfendi I would like to merge this PR.
But I found the t/ocsp.t TEST 19 can not pass.
got the following error other than that in the test case.
Would you please help add some doc about how to generate the revoke ocsp.

2022/01/08 13:54:59 [error] 589#0: *8 [lua] ssl_certificate_by_lua:22: failed to validate OCSP response: certificate status not found in the OCSP response. next_update: nil, context: ssl_certificate_by_lua*, client: unix:, server: unix:/home/ljl/code/openresty/lua-resty-core/t/servroot/html/nginx.sock

@zhuizhuhaomeng zhuizhuhaomeng merged commit 229b6d6 into openresty:master Mar 10, 2024
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants