Skip to content

Commit

Permalink
Simplified parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
reinkrul committed Nov 12, 2024
1 parent c3c8f13 commit d611850
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
9 changes: 1 addition & 8 deletions uzi_vc_issuer/ura_issuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"crypto/sha1"
"crypto/x509"
"encoding/base64"
"encoding/json"
"encoding/pem"
"errors"
"fmt"
Expand Down Expand Up @@ -77,14 +76,8 @@ func Issue(certificateFile string, signingKeyFile string, subjectDID string, all
if err != nil {
return "", err
}
credentialJSON, err := json.Marshal(credential)
if err != nil {
return "", err
}
jwtString := credential.Raw()
validator := uzi_vc_validator.NewUraValidator(allowTestUraCa, allowSelfSignedCa)
jwtString := string(credentialJSON)
jwtString = jwtString[1:] // Chop start
jwtString = jwtString[:len(jwtString)-1] // Chop end
err = validator.Validate(jwtString)
if err != nil {
return "", err
Expand Down
5 changes: 1 addition & 4 deletions uzi_vc_validator/ura_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/sha1"
"crypto/x509"
"encoding/base64"
"encoding/json"
"fmt"
"github.com/lestrrat-go/jwx/v2/cert"
"github.com/lestrrat-go/jwx/v2/jwa"
Expand Down Expand Up @@ -38,9 +37,7 @@ type JwtHeaderValues struct {
}

func (u UraValidatorImpl) Validate(jwtString string) error {
credential := &vc.VerifiableCredential{}
marshal, _ := json.Marshal(jwtString)
err := json.Unmarshal(marshal, credential)
credential, err := vc.ParseVerifiableCredential(jwtString)
if err != nil {
return err
}
Expand Down

0 comments on commit d611850

Please sign in to comment.