[gnutls-devel] GnuTLS | 32bit time issues with gnutls_x509_crt_[get, set]-*-time (#1670)
Read-only notification of GnuTLS library development activities
gnutls-devel at lists.gnutls.org
Tue Mar 4 17:03:55 CET 2025
Dariqq commented on a discussion: https://gitlab.com/gnutls/gnutls/-/issues/1670#note_2378607994
I added a print statement in the guile code after the call to gnutls_x509_crt_get_expiration_time and before it gets converted back to scheme. It looks something like this
```c
gnutls_x509_crt_t c_cert;
time_t c_time;
c_cert = scm_to_gnutls_x509_certificate (cert, 1, FUNC_NAME);
c_time = gnutls_x509_crt_get_expiration_time (c_cert);
printf("%ld\n", c_time); // c_time has already overflown here.
return scm_from_int (c_time);
```
This made me think that it is not an issue with the bindings.
The exception for setting a value should just correspond to a gnutls error which hints at the same issue.
However I am unable to reproduce this when i use C directly:
```c
#include <gnutls/x509.h>
#include <gnutls/gnutls.h>
#include <stdio.h>
// gcc -o main main.c -lgnutls
int
main ()
{
int err;
gnutls_x509_crt_t cert;
time_t time = 2147483648; // 2^31
err = gnutls_x509_crt_init (&cert);
if(err == 0)
{
printf("%ld\n", time);
err = gnutls_x509_crt_set_expiration_time(cert, time);
printf("%d: %s\n", err, gnutls_strerror(err));
}
}
// ./main
// 2147483648
// 0: Success
```
Also I am when I try to read my certificate and get the expiration time directly from C `gnutls_x509_crt_get_expiration_time` returns the correct time of 2686847494.
So a scheme problem after all? Apologies for the false alarm.
I am very confused on what is happening.
--
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/issues/1670#note_2378607994
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20250304/afb96ef2/attachment.html>
More information about the Gnutls-devel
mailing list