Skip to content

Conversation

@StephenWall
Copy link
Contributor

This changes the days parameter of openssl_csr_sign() to a validity parameter, which can be either an integer specifying the number of days the certificate is to be valid for (compatible with current usage), or it can be an array of two integer or string values, representing the notBefore and notAfter times to use for the certificate. If they are integers or numeric strings, they are to be a time_t value. If they are non-numeric strings, they are to be an ASN.1 timestamp (YYMMDDHHMMSSZ or YYYYMMDDHHMMSSZ).

X509_gmtime_adj(X509_getm_notBefore(new_cert), 0);
X509_gmtime_adj(X509_getm_notAfter(new_cert), 60*60*24*num_days);
if (num_days == -1) {
ASN1_TIME_set(X509_getm_notBefore(new_cert), from_time);
Copy link
Contributor

Choose a reason for hiding this comment

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

what about accepting DateTimeInterface?

Copy link
Contributor Author

@StephenWall StephenWall Oct 30, 2025

Choose a reason for hiding this comment

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

Not sure how to do that...

} else if (Z_TYPE_P(tmp) == IS_OBJECT && Z_OBJCE_P(tmp) == php_date_get_date_ce) {

but then what? How would I turn that object into a time_t?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe like this?

php_date_obj *datetime = php_date_obj_from_obj(Z_OBJ(tmp));
zval timestamp;
zend_call_method_with_0_params(date_obj, php_date_get_date_ce(), NULL, "gettimestamp", &timestamp);
if (Z_TYPE(timestamp) == IS_LONG) {
    from = Z_LVAL_P(timestamp);
}

… a CSR

This changes the `days` parameter of `openssl_csr_sign()` to a
`validity` parameter, which can be either an integer specifying the
number of days the certificate is to be valid for (compatible with
current usage), or it can be an array of two integer or string values,
representing the notBefore and notAfter times to use for the
certificate.  If they are integers or numeric strings, they are to be a
time_t value.  If they are non-numeric strings, they are to be an ASN.1
timestamp (YYMMDDHHMMSSZ or YYYYMMDDHHMMSSZ).
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.

2 participants