Skip to content

crypto: add extensions property to X509Certificate - #48780

Closed
mertcanaltin wants to merge 0 commit into
nodejs:mainfrom
mertcanaltin:dev-48730
Closed

mertcanaltin wants to merge 0 commit into
nodejs:mainfrom
mertcanaltin:dev-48730

Conversation

@mertcanaltin

Copy link
Copy Markdown
Member

This pull request adds an enhanced property to the X509Certificate class, providing additional functionality for X.509 certificates. The new property improves the handling of certificate subjects, issuers, and other related information. This enhancement enhances the overall capabilities and usability of the X509Certificate class

issue:#48730
fyi @jeffsec-aws

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-github-bot added crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run. labels Jul 15, 2023
@mscdex

mscdex commented Jul 15, 2023

Copy link
Copy Markdown
Contributor

This needs tests.

Comment thread test/parallel/test-x509-escaping.js Outdated
@mertcanaltin
mertcanaltin requested a review from mscdex July 15, 2023 16:51

@panva panva left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

May I suggest to rename certificateExtensions to just extensions. Also then update the first commit message (and the PR title) to crypto: add extensions property to X509Certificate?

@panva
panva requested a review from tniessen July 15, 2023 17:02
@panva

panva commented Jul 15, 2023 •

Copy link
Copy Markdown
Member

I believe the tests belong better to test/parallel/test-crypto-x509.js. A test for accessing the property when there are no extensions would also be welcome.

Not being familiar with extensions myself so apologizies if the following questions are just plain irrelevant. I wonder if an extension can be present multiple times, in which case how would such extension be returned? Are there structured extensions? Or extensions who's value is not a string?

@tniessen is there a reason you didn't expose this in the first place?

@mertcanaltin
mertcanaltin force-pushed the dev-48730 branch 2 times, most recently from 11d9028 to 6916509 Compare July 15, 2023 17:18
@panva panva changed the title crypto: update X509Certificate property crypto: add extensions property to X509Certificate Jul 15, 2023
@mertcanaltin

Copy link
Copy Markdown
Member Author

When I look before the test, I get the output of x509.extensions undefined. Could it be because I cannot access it because it is undefined?

@mertcanaltin
mertcanaltin requested a review from panva July 16, 2023 08:33
@panva

panva commented Jul 16, 2023

Copy link
Copy Markdown
Member

I am unfamiliar with the underlying implementation.

@jeffsec-aws

Copy link
Copy Markdown

Nice work.

Extensions can be of various different types and content. Now they only appear one in terms of key (an OID see for example: https://access.redhat.com/documentation/en-us/red_hat_certificate_system/9/html/administration_guide/standard_x.509_v3_certificate_extensions) but can have multiple values in a form of an array.

@mertcanaltin

mertcanaltin commented Jul 17, 2023 •

Copy link
Copy Markdown
Member Author

@mscdex @panva @tniessen @jeffsec-aws hello I will be very happy if you review it, thank you very much

@panva panva left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are there hardcoded values in the implementation?

@mertcanaltin

Copy link
Copy Markdown
Member Author

@panva How can I generate a certificate with extensions? I will use it in my test instead of hardcoded.

i will be using it in my test code

@panva

panva commented Jul 18, 2023

Copy link
Copy Markdown
Member

@mertcanaltin I am really not able to be of that kind of assistance.

@jeffsec-aws

Copy link
Copy Markdown

What method do you want to use to generate those certificates? Would OpenSSL commands help?

@mertcanaltin

Copy link
Copy Markdown
Member Author

What method do you want to use to generate those certificates? Would OpenSSL commands help?

yes it will help

@mertcanaltin
mertcanaltin requested a review from panva July 29, 2023 21:17

@panva panva left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'll quote my earlier concern which needs to be settled before this can progress.

Not being familiar with extensions myself so apologizies if the following questions are just plain irrelevant. I wonder if an extension can be present multiple times, in which case how would such extension be returned? Are there structured extensions? Or extensions who's value is not a string?

These examples would need tests added and the documentation for this method also has to be added.

Comment thread test/parallel/test-crypto-x509.js Outdated
@mertcanaltin

Copy link
Copy Markdown
Member Author

Yes, I added this certificate to fixtures instead of hardcoding it and tried to fix my test @panva

@jeffsec-aws

Copy link
Copy Markdown

I'll quote my earlier concern which needs to be settled before this can progress.

Not being familiar with extensions myself so apologizies if the following questions are just plain irrelevant. I wonder if an extension can be present multiple times, in which case how would such extension be returned? Are there structured extensions? Or extensions who's value is not a string?

These examples would need tests added and the documentation for this method also has to be added.

And I answered to you. Extensions are referenced by OID so the key always appears only once. Now the value can be array of value for some extensions like OCSP Responder URL

@mertcanaltin
mertcanaltin requested a review from panva July 31, 2023 18:52
@mertcanaltin

mertcanaltin commented Aug 2, 2023 •

Copy link
Copy Markdown
Member Author

Hello @jeffsec-aws,@panva I would appreciate it if you could review this Pull Request. Thank you!

@Trott

Trott commented Sep 19, 2023

Copy link
Copy Markdown
Member

@nodejs/crypto This could probably use some reviews (or re-reviews for the people that have already reviewed it).

@Trott Trott added the commit-queue-squash PRs the Commit Queue should land as one squashed commit. label Sep 19, 2023
@mertcanaltin
mertcanaltin requested a review from panva November 3, 2023 07:23
@mertcanaltin

Copy link
Copy Markdown
Member Author

greetings I triggered you guys again very sorry I wonder if I have a chance to get an update here

panva
panva previously requested changes Nov 3, 2023

@panva panva left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am unable to review the implementation, aside of that this lacks sufficient test coverage and update to documentation.

@panva panva added the c++ Issues and PRs that require attention from people who are familiar with C++. label Nov 3, 2023
@mertcanaltin

mertcanaltin commented Nov 3, 2023 •

Copy link
Copy Markdown
Member Author

I am unable to review the implementation, aside of that this lacks sufficient test coverage and update to documentation.

thank you very much for your suggestion, I updated the document @panva

@mertcanaltin
mertcanaltin requested a review from panva November 3, 2023 18:45
@mertcanaltin

Copy link
Copy Markdown
Member Author

greetings I updated the document and I think I got stuck on a flakky test @panva

Comment thread doc/api/crypto.md Outdated
@panva

panva commented Nov 8, 2023 •

Copy link
Copy Markdown
Member

Aside from my above suggestion to fix and simplify the docs entry I believe this lacks sufficient test coverage.

Note that I can not review the c++ implementation

@mertcanaltin

Copy link
Copy Markdown
Member Author

Aside from my above suggestion to fix and simplify the docs entry I believe this lacks sufficient test coverage.

Note that I can not review the c++ implementation

thank you very much for your suggestions, here I created a crypto-extensions.pem certificate for testing and tested the subjectAltName in the extension, in fact, I would be very happy if you have a suggestion.

@mertcanaltin
mertcanaltin requested a review from panva November 12, 2023 13:40
@panva
panva removed their request for review November 12, 2023 14:11
@panva
panva dismissed their stale review November 12, 2023 14:12

dismissing one review, i still think test coverage is not there and someone else than me has to review the c++ code, there is no further point in asking me to review this,

@tniessen tniessen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Node.js has made the mistake of representing structured ASN.1 data as strings in the past, which has led to various issues. Most notable, perhaps, CVE-2021-44532 and CVE-2021-44533, which were a nightmare to fix without breaking the ecosystem.

At this point, we should be extremely careful about exposing any human-readable information provided by OpenSSL for anything besides debugging purposes. These text formats are not meant to be processed automatically, and OpenSSL generally provides no stability guarantees.

Comment thread doc/api/crypto.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This needs a lot more information, especially w.r.t. the exact structure of the returned object.

Comment thread src/crypto/crypto_common.cc Outdated
Comment thread src/crypto/crypto_common.cc Outdated
Comment thread src/crypto/crypto_common.cc Outdated
Comment thread src/crypto/crypto_common.cc Outdated
Comment thread src/crypto/crypto_common.cc Outdated
Comment thread src/crypto/crypto_common.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should modify test/fixtures/keys/Makefile such that it can be used to generate this certificate, unless that is not feasible for some reason.

@mertcanaltin

Copy link
Copy Markdown
Member Author

thank you very much for your suggestions I have applied a few changes and I hope I have followed the correct steps

@mertcanaltin
mertcanaltin requested a review from jasnell December 9, 2023 16:35
@mertcanaltin
mertcanaltin requested a review from panva January 3, 2024 20:53
@panva
panva removed their request for review January 3, 2024 22:00
@mertcanaltin

Copy link
Copy Markdown
Member Author

@tniessen greetings, I would be very happy if you could take a look when you have time, again many thanks for your support

@mertcanaltin

Copy link
Copy Markdown
Member Author

Greetings, I want to improve this place very much, do not hesitate to make suggestions when appropriate ❤️

@marco-ippolito

Copy link
Copy Markdown
Member

There are still a bunch of tests failing and some comments from @tniessen that have not been addressed

@mertcanaltin

Copy link
Copy Markdown
Member Author

@tniessen Hello, I would like to move this place forward, do you have an update?

@mertcanaltin

Copy link
Copy Markdown
Member Author

hello this is my old first attempt to contribute, I will try to fix this place if you have any suggestions please feel free

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash PRs the Commit Queue should land as one squashed commit. crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants