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

Create self signed chain from command line #1

Merged
merged 15 commits into from
Oct 15, 2024
Merged

Conversation

stevenvegt
Copy link
Member

Add functionality to create a test chain from the commandline Refactor things:

  • Cert chain always in fixed order: signCert, int2, int1, root.
  • *[]x509.Certificate -> []*x509.Certificate
  • *[][]byte -> [][]byte

Add functionality to create a test chain from the commandline
Refactor things:
- Cert chain always in fixed order
- `*[]x509.Certificate` -> `[]*x509.Certificate`
- `*[][]byte` -> `[][]byte`
* main:
  Update README.md with test coverage
  Add env var
  Update go.yml
  Create go test workflow
  Update mockgen source paths in makefile
  Remove unused interfaces and simplify parser usage
  Refactor: remove PemReader interface and simplify usage
  Remove DidCreator and DidParser interfaces
  Create dependabot.yml
  Add Code Climate batch
  Reverse chain order in the x5c header.
  Move FixChainHeaders from x509_test_utils.go to x509_cert.go

# Conflicts:
#	did_x509/did_x509.go
#	did_x509/did_x509_test.go
#	pem/pem_reader.go
#	uzi_vc_issuer/ura_issuer.go
#	x509_cert/x509_cert.go
- Multiple CA roots co-exist when the -t flag is enabled.
Removed two debug print statements that printed extension IDs and other name types. These statements were cluttering the output and are not necessary for the final implementation.
Introduce `allowUziTestCa` and `allowSelfSignedCa` flags to UraValidatorImpl for more flexible certificate chain validation. Refactor the validation logic to handle these new flags appropriately, ensuring better support for various CA configurations.
Re-enable the use of findSigningCertificate to ensure proper certificate validation based on X509 thumbprint. Remove hardcoding of the signingCert as first certificate in the chain and handle potential errors appropriately.
Improved the test-cert command to specify UZI, URA, and AGB parameters instead of a single identifier. This change enhances flexibility and allows for a more precise definition of test certificates. Updated help text for better clarity and added comments to explain the format of the otherName field.
Previously, errors when writing "chain.pem" and "signing_key.pem" were not handled separately. This change ensures that each file write operation checks for errors independently and exits with an error message if a write fails.
Updated `FormatDid` function to use a more descriptive variable `caCert` instead of `ca`. Modified the `FindRootCertificate` function to use the `x509_cert.IsRootCa` helper function for improved readability and consistency in the root CA check.
* main:
  Fix JSON unmarshalling issue in Validate method.
…ame seems to be the field that identifies the signer and subject.

Updated CertTemplate function to accept an additional "organization" parameter, which allows different organization names for certificates. Adjusted related calls and modified default certificate values to reflect these changes.
Introduce a new `subject_did` field in the `TestCert` struct with a default value. Update the `test-cert` command case to handle this new parameter and adjust the VC issuance logic.
@rolandgroen
Copy link
Collaborator

@stevenvegt Please check if you're happy with the changes I did.

@rolandgroen rolandgroen changed the title Create test chain from command line Create self signed chain from command line Oct 15, 2024
… method

Replaced the string formatting approach with direct JSON marshaling to prevent potentially unsafe quoting.
Renamed the loop variable from 'cert' to 'c' to prevent a naming collision with the cert import.
A comment was added to the DebugUnmarshall method to indicate that it should be retained for future debugging purposes.
Copy link
Collaborator

@rolandgroen rolandgroen left a comment

Choose a reason for hiding this comment

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

The PR looks fine from here. Accepted.

@@ -4,19 +4,27 @@ import (
"fmt"
"github.com/alecthomas/kong"
"github.com/nuts-foundation/uzi-did-x509-issuer/uzi_vc_issuer"
"github.com/nuts-foundation/uzi-did-x509-issuer/x509_cert"
"os"
)

type VC struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I did some refactoring around the concept op "test" and "self signed". The "test" stuff are certificates signed by the Test UZI Root Ca, the "self signed" stuff you added uses a own CA. To determine the latter case, the code checks if the certificates file is len(c) > 1. In that case it will use other validation logic than if not.

@rolandgroen rolandgroen merged commit abe731e into main Oct 15, 2024
3 checks passed
@rolandgroen rolandgroen deleted the use-test-chain branch October 15, 2024 11:57
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