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

Fix for CSharp SetCustomExtension #239

Merged
merged 3 commits into from
Aug 29, 2022
Merged

Fix for CSharp SetCustomExtension #239

merged 3 commits into from
Aug 29, 2022

Conversation

anhu
Copy link
Member

@anhu anhu commented Aug 25, 2022

Tested with the CSharp wrapper tests and inspected the CSR.

# wolfSSL
./configure --enable-wolftpm --enable-certgen --enable-asn=template \
    CFLAGS="-DWOLFSSL_CUSTOM_OID -DHAVE_OID_ENCODING"
make && sudo make install

# wolfTPM
./configure --enable-swtpm --enable-debug
make && sudo make install
cd wrapper/CSharp
mcs wolfTPM.cs wolfTPM-tests.cs -r:/usr/lib/cli/nunit.framework-2.6.3/nunit.framework.dll -t:library
LD_LIBRARY_PATH=../../src/.libs/ nunit-console wolfTPM.dll
openssl req -inform pem -in csr_customExt.pem -text

Fixes ZD14713

@anhu anhu requested a review from dgarske August 25, 2022 20:25
defined(HAVE_OID_ENCODING)

#ifndef WOLFTPM2_NUM_CUSTOM_EXT
#define WOLFTPM2_NUM_CUSTOM_EXT 16
Copy link
Contributor

Choose a reason for hiding this comment

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

Can’t we get the defaults from wolfCrypt?

typedef struct WOLFTPM2_CSR {
#if defined(WOLFSSL_ASN_TEMPLATE) && defined(WOLFSSL_CUSTOM_OID) && \
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer these defines to be outside the typedef although I realize it works this way too.

@@ -540,6 +540,8 @@ public void TryGenerateCSRCustomOID()
Assert.That(rc, Is.GreaterThan(0));

Console.WriteLine("CSR PEM {0} bytes", rc.ToString());
var writer = new BinaryWriter(File.OpenWrite("csr.pem"));
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be handy. Any issue running it over and over?

Copy link
Member Author

Choose a reason for hiding this comment

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

Glad you like it.!

If you used over and over then it would probably write all the things to the same file? I would think the writer needs to fall out of scope and then the garbage collector would then close the file?

I can break this out to its own function. Then it could fall out of scope and it would make things clearer.

@dgarske dgarske assigned anhu and unassigned dgarske Aug 25, 2022
@anhu anhu requested a review from dgarske August 26, 2022 13:58
@anhu anhu assigned dgarske and unassigned anhu Aug 26, 2022
@anhu
Copy link
Member Author

anhu commented Aug 26, 2022

Please do not merge. Still waiting for customer feedback.

@dgarske dgarske changed the title Save OIDs to a persistent buffer. Fix for CSharp SetCustomExtension Aug 26, 2022
@anhu
Copy link
Member Author

anhu commented Aug 26, 2022

I have tested @dgarske 's lastest change. It works as expected and I approve.

@dgarske
Copy link
Contributor

dgarske commented Aug 29, 2022

Going to go ahead and merge. I believe this fix solves things for the customer.

@dgarske dgarske merged commit ed9c746 into wolfSSL:master Aug 29, 2022
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

Successfully merging this pull request may close these issues.

2 participants