-
Notifications
You must be signed in to change notification settings - Fork 68
Tokengen should also work without signing key of auditor and issuer #299 #300
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
Conversation
…ssuer #299 Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
token/core/cmd/pp/common/common.go
Outdated
| b, _ := pem.Decode(bytes) | ||
| if b == nil { // TODO: also check that the type is what we expect (cert vs key..) | ||
| return nil, errors.Errorf("no pem content for file %s", file) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you just want to check if bytes contains at least a valid pem decoded block, right? What is multiple blocks are available?
| if err != nil { | ||
| return nil, errors.Wrapf(err, "failed to load certificates from %s", signcertDir) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant error check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the folder might contain no files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I am saying is that we check the error twice! in line 52 and 58.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad, sorry
token/core/cmd/pp/common/common.go
Outdated
|
|
||
| "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/core/generic/msp/x509" | ||
| msp3 "github.com/hyperledger/fabric/msp" | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty line
cmd/tokengen/main_test.go
Outdated
| "github.com/hyperledger-labs/fabric-token-sdk/token/core/cmd/pp/common" | ||
|
|
||
| "github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/crypto" | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty lines
…ssuer #299 Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
| if err != nil { | ||
| return nil, errors.Wrapf(err, "failed to load certificates from %s", signcertDir) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I am saying is that we check the error twice! in line 52 and 58.
token/core/cmd/pp/common/common.go
Outdated
| return fileCont, nil | ||
| } | ||
|
|
||
| func ReadPemFile(file string) ([]byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's give the function some documentation and even change the name. ReadPemFile is a very generic name, however, the current impl returns errors if the content in the pem file it not a cert, or there are more than one entry.
Maybe call it ReadCertFromPemFile(file string) explaining that it returns the first item from a pem file if exists. If needed we can later add ReadCertsFromPemFile(...) to parse the entire file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
| if len(rest) != 0 { | ||
| return nil, errors.Errorf("extra content after pem file %s", file) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could just ignore the rest. If there are more certs in the file, we don't care, do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say, let's constrain to a single certificate in the file
| return nil, errors.Errorf("pem file %s is not a certificate", file) | ||
| } | ||
|
|
||
| return bytes, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we just return b?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we force only one cert, we can return directly the bytes
…ssuer #299 Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
mbrandenburger
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
(#300) Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
- Update readme with link to gopath doc - Enforce GOPATH is set when using integration test suite Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
Signed-off-by: Angelo De Caro adc@zurich.ibm.com