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

Problem with tls_certificate_set_copy_date #87

Open
headscott opened this issue Nov 3, 2023 · 1 comment
Open

Problem with tls_certificate_set_copy_date #87

headscott opened this issue Nov 3, 2023 · 1 comment

Comments

@headscott
Copy link

I encountered a problem in the function tls_certificate_set_copy: you set (*member)[len] = 0; but by that you overwrite the seconds of the validity you wanted to save. It should be (*member)[len + 2] = 0; i think. At least this worked for me.

@headscott
Copy link
Author

headscott commented Nov 6, 2023

There is another small problem with the version saved in the certificate: if the certificate is X.509v1 you save cert->version = 0 but then you can't print it in the certificate_to_string method, cause you test for cert->version != 0. I would say you should do the following in the _private_asn1_parse function:

if (length == 1)
                           cert->version = buffer[pos] + 1;
#ifdef TLS_X509_V1_SUPPORT
                       else
                           cert->version = 1;
                       idx++;
#endif

instead of

if (length == 1)
                            cert->version = buffer[pos];
#ifdef TLS_X509_V1_SUPPORT
                        else
                            cert->version = 0;
                        idx++;
#endif

But then you also have to do

if (cert) {
            if ((cert->version == 3) 
#ifdef TLS_X509_V1_SUPPORT
                || (cert->version == 1)
#endif
            ) {

in the load methods for both certificates

instead of

if (cert) {
            if ((cert->version == 2) 
#ifdef TLS_X509_V1_SUPPORT
                || (cert->version == 0)
#endif
            ) {

By that you will also now print the correct version spelling in the certificate_to_string method. At least this is how I think this would work. For me it does

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant