-
Notifications
You must be signed in to change notification settings - Fork 2
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
NOISSUE - Refactor CSR generation #55
Changes from 11 commits
eba2f56
290d256
459ffb3
67e51e2
cd6f2fd
c795d21
5374de7
8588a8f
a3fcde7
670bc52
5ccc6f5
f21503f
2421ea4
2dbf045
44e5e41
01eb0bb
c412393
024409c
98275e7
85dedd2
11972ae
86ceb56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -314,71 +314,38 @@ func createCSREndpoint(svc certs.Service) endpoint.Endpoint { | |
return func(ctx context.Context, request interface{}) (response interface{}, err error) { | ||
req := request.(createCSRReq) | ||
if err := req.validate(); err != nil { | ||
return createCSRRes{created: false}, err | ||
return createCSRRes{}, err | ||
} | ||
|
||
csr, err := svc.CreateCSR(ctx, req.Metadata, req.Metadata.EntityID, req.privKey) | ||
csr, err := svc.CreateCSR(ctx, req.Metadata, req.privKey) | ||
if err != nil { | ||
return createCSRRes{created: false}, err | ||
return createCSRRes{}, err | ||
} | ||
|
||
return createCSRRes{ | ||
created: true, | ||
CSR: csr, | ||
CSR: string(csr.CSR), | ||
}, nil | ||
} | ||
} | ||
|
||
func signCSREndpoint(svc certs.Service) endpoint.Endpoint { | ||
func issueFromCSREndpoint(svc certs.Service) endpoint.Endpoint { | ||
return func(ctx context.Context, request interface{}) (response interface{}, err error) { | ||
req := request.(SignCSRReq) | ||
req := request.(IssueFromCSRReq) | ||
if err := req.validate(); err != nil { | ||
return signCSRRes{signed: false}, err | ||
return issueFromCSRRes{}, err | ||
} | ||
|
||
err = svc.SignCSR(ctx, req.csrID, req.approve) | ||
cert, err := svc.IssueFromCSR(ctx, req.entityID, req.ttl, certs.CSR{CSR: []byte(req.CSR), PrivateKey: []byte(req.PrivateKey)}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is the private key uploaded, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you don't need the private key when signing the certificate, you only need the public key. the point of this endpoint is for users who want to keep their private keys secure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me make that change |
||
if err != nil { | ||
return signCSRRes{signed: false}, err | ||
return issueFromCSRRes{}, err | ||
} | ||
|
||
return signCSRRes{ | ||
signed: true, | ||
}, nil | ||
} | ||
} | ||
|
||
func retrieveCSREndpoint(svc certs.Service) endpoint.Endpoint { | ||
return func(ctx context.Context, request interface{}) (response interface{}, err error) { | ||
req := request.(retrieveCSRReq) | ||
if err := req.validate(); err != nil { | ||
return retrieveCSRRes{}, err | ||
} | ||
|
||
csr, err := svc.RetrieveCSR(ctx, req.csrID) | ||
if err != nil { | ||
return retrieveCSRRes{}, err | ||
} | ||
|
||
return retrieveCSRRes{ | ||
CSR: csr, | ||
}, nil | ||
} | ||
} | ||
|
||
func listCSRsEndpoint(svc certs.Service) endpoint.Endpoint { | ||
return func(ctx context.Context, request interface{}) (response interface{}, err error) { | ||
req := request.(listCSRsReq) | ||
if err := req.validate(); err != nil { | ||
return listCSRsRes{}, err | ||
} | ||
|
||
cp, err := svc.ListCSRs(ctx, req.pm) | ||
if err != nil { | ||
return listCSRsRes{}, err | ||
} | ||
|
||
return listCSRsRes{ | ||
cp, | ||
return issueFromCSRRes{ | ||
SerialNumber: cert.SerialNumber, | ||
Certificate: string(cert.Certificate), | ||
Revoked: cert.Revoked, | ||
ExpiryTime: cert.ExpiryTime, | ||
EntityID: cert.EntityID, | ||
}, 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.
what is the purpose of create csr endpoint, users can create csrs using openssl
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.
Its an alternative if the user doesn't want to use openssl. The idea is to make certs more generic.
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.
move to cli tool, no need to call an online api to create a CSR