Skip to content

Commit

Permalink
Add subject_did field and update test-cert case
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rolandgroen committed Oct 14, 2024
1 parent b09d7cc commit b52af6f
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ type VC struct {
}

type TestCert struct {
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."`
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."`
SubjectDID string `arg:"" default:"did:web:example.com:test" name:"subject_did" help:"The subject DID of the VC." type:"key"`
}

var CLI struct {
Expand Down Expand Up @@ -47,7 +48,7 @@ func main() {
os.Exit(-1)
}
println(jwt)
case "test-cert <uzi> <ura> <agb>":
case "test-cert <uzi> <ura> <agb>", "test-cert <uzi> <ura> <agb> <subject_did>":
// 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>
Expand Down Expand Up @@ -80,7 +81,18 @@ func main() {
fmt.Println(err)
os.Exit(-1)
}

vc := VC{
CertificateFile: "chain.pem",
SigningKey: "signing_key.pem",
SubjectDID: cli.TestCert.SubjectDID,
Test: false,
}
jwt, err := issueVc(vc)
if err != nil {
fmt.Println(err)
os.Exit(-1)
}
println(jwt)
default:
fmt.Println("Unknown command")
os.Exit(-1)
Expand Down

0 comments on commit b52af6f

Please sign in to comment.