-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
AsnEncodedData.Format return empty for CRL extension in Linux #79265
Comments
Tagging subscribers to this area: @dotnet/area-system-security, @vcsjones Issue DetailsDescriptionAsnEncodedData.Format return empty for CRL extension in Linux with below code snippet:
It works as expected in Windows which outputs:
However in Linux, it output nothing. Reproduction StepsRepo attached: X509Extension.zip Expected behaviorThe code snippet above should return the correct CRL info in Linux as in Windows Actual behaviorIt returns empty. Regression?No response Known WorkaroundsNo response Configuration
Other informationNo response
|
On macOS this outputs the hex string, which is the behavior for "I don't have special formatting rules for this". On Windows, is works as described. On Linux, it outputs a line feed ( On a different note however, I would caution using You can use the |
So, something is not quite right here with OpenSSL. Doing this in plain C: #include <openssl/bio.h>
#include <openssl/objects.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
int main(int argc, char *argv[])
{
unsigned char crlDistributionPoint[56] = {
0x30, 0x36, 0x30, 0x34, 0xa0, 0x32, 0xa0, 0x30, 0x86, 0x2e, 0x68, 0x74,
0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x72, 0x6c, 0x2e, 0x67, 0x6c, 0x6f,
0x62, 0x61, 0x6c, 0x73, 0x69, 0x67, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
0x67, 0x73, 0x72, 0x73, 0x61, 0x6f, 0x76, 0x73, 0x73, 0x6c, 0x63, 0x61,
0x32, 0x30, 0x31, 0x38, 0x2e, 0x63, 0x72, 0x6c };
ASN1_OBJECT* oid = OBJ_txt2obj("2.5.29.31", 1);
ASN1_OCTET_STRING* contents = ASN1_OCTET_STRING_new();
ASN1_OCTET_STRING_set(contents, crlDistributionPoint, sizeof(crlDistributionPoint));
X509_EXTENSION* ext = X509_EXTENSION_create_by_OBJ(NULL, oid, 0, contents);
BIO* stdoutBio = BIO_new_fp(stdout, BIO_NOCLOSE);
X509V3_EXT_print(stdoutBio, ext, X509V3_EXT_DEFAULT, 0);
X509_EXTENSION_free(ext);
ASN1_OCTET_STRING_free(contents);
ASN1_OBJECT_free(oid);
} And compiling with
That does correctly print:
So this appears to be a valid issue. I'll keep looking in to it. |
Okay, so the issue is our use of Line 63 in e1081df
We assume it is going to do the read all in one go. From the docs:
So it reads a line and writes it to a buffer, but it didn't read it to completion. We basically need to do the equivalent of "keep reading in to the buffer until there is no more data to be read"*. *The irony of this is not lost on me. |
Description
AsnEncodedData.Format return empty for CRL extension in Linux with below code snippet:
It works as expected in Windows which outputs:
However in Linux, it output nothing.
Reproduction Steps
Repo attached: X509Extension.zip
Expected behavior
The code snippet above should return the correct CRL info in Linux as in Windows
Actual behavior
It returns empty.
Regression?
No response
Known Workarounds
No response
Configuration
Other information
No response
The text was updated successfully, but these errors were encountered: