Skip to content

Commit

Permalink
Update test-cert CLI to include UZI, URA, and AGB parameters
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rolandgroen committed Oct 14, 2024
1 parent 622cef4 commit b093d0f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ import (
)

type VC struct {
CertificateFile string `arg:"" name:"certificate_file" help:"Certificate PEM file." type:"existingfile"`
CertificateFile string `arg:"" name:"certificate_file" help:"Certificate PEM file. If the file contains a chain, the chain will be used for signing." type:"existingfile"`
SigningKey string `arg:"" name:"signing_key" help:"PEM key for signing." type:"existingfile"`
SubjectDID string `arg:"" name:"subject_did" help:"The subject DID of the VC." type:"key"`
Test bool `short:"t" help:"Allow test certificates."`
Test bool `short:"t" help:"Allow for certificates signed by the TEST UZI Root CA."`
}

type TestCert struct {
Identifier string `arg:"" name:"identifier" help:"Identifier for the test certificate such as an URA or UZI number."`
Uzi string `arg:"" name:"uzi" help:"The UZI number for the test certificate."`
Ura string `arg:"" name:"ura" help:"The URA number for the test certificate."`
Agb string `arg:"" name:"agb" help:"The AGB code for the test certificate."`
}

var CLI struct {
Expand Down Expand Up @@ -45,10 +47,13 @@ func main() {
os.Exit(-1)
}
println(jwt)
case "test-cert <identifier>":
otherName := fmt.Sprintf("2.16.528.1.1007.1.%s", cli.TestCert.Identifier)
case "test-cert <uzi> <ura> <agb>":
// Format is 2.16.528.1.1007.99.2110-1-900030787-S-90000380-00.000-11223344
// <OID CA>-<versie-nr>-<UZI-nr>-<pastype>-<Abonnee-nr>-<rol>-<AGB-code>
// 2.16.528.1.1007.99.2110-1-<UZI-nr>-S-<Abonnee-nr>-00.000-<AGB-code>
otherName := fmt.Sprintf("2.16.528.1.1007.99.2110-1-%s-S-%s-00.000-%s", cli.TestCert.Uzi, cli.TestCert.Ura, cli.TestCert.Agb)
fmt.Println("Building certificate chain for identifier:", otherName)
chain, _, _, privKey, _, err := x509_cert.BuildCertChain(cli.TestCert.Identifier)
chain, _, _, privKey, _, err := x509_cert.BuildCertChain(otherName)
if err != nil {
fmt.Println(err)
os.Exit(-1)
Expand Down

0 comments on commit b093d0f

Please sign in to comment.