@@ -50,6 +50,19 @@ type IssueResponse struct {
5050 Auth * string `json:"auth"`
5151}
5252
53+ // SignRequest
54+ type SignRequest struct {
55+ CSR string `json:"csr" validation:"required"`
56+ CommonName string `json:"common_name" validation:"required"`
57+ AltNames string `json:"alt_names"`
58+ OtherSans string `json:"other_sans"`
59+ IPSans string `json:"ip_sans"`
60+ URISans string `json:"uri_sans"`
61+ TTL string `json:"ttl,omitempty"`
62+ Format string `json:"format" validation:"required" enum:"pem|der|pem_bundle"`
63+ ExcludeCNFromSans bool `json:"exclude_cn_from_sans"`
64+ }
65+
5366// ServiceOptions
5467type ServiceOptions struct {
5568}
@@ -160,6 +173,29 @@ func (d *IssueData) GetPrivateKey() (interface{}, error) {
160173 return nil , ErrInvalidPrivateKey
161174}
162175
176+ // Sign
177+ func (c * ServicesService ) Sign (logicalPath , roleName string , signRequest SignRequest , options ... OptionFunc ) (* IssueResponse , * Response , error ) {
178+ if err := c .validate .Struct (signRequest ); err != nil {
179+ return nil , nil , err
180+ }
181+ req , err := c .client .NewServiceRequest (http .MethodPost , "core/pki/api/" + logicalPath + "/sign/" + roleName , & signRequest , options )
182+ if err != nil {
183+ return nil , nil , err
184+ }
185+ var responseStruct struct {
186+ IssueResponse
187+ ErrorResponse
188+ }
189+ resp , err := c .client .Do (req , & responseStruct )
190+ if err != nil {
191+ return nil , nil , err
192+ }
193+ if resp == nil {
194+ return nil , nil , ErrEmptyResult
195+ }
196+ return & responseStruct .IssueResponse , resp , nil
197+ }
198+
163199// IssueCertificate
164200func (c * ServicesService ) IssueCertificate (logicalPath , roleName string , request CertificateRequest , options ... OptionFunc ) (* IssueResponse , * Response , error ) {
165201 req , err := c .client .NewServiceRequest (http .MethodPost , "core/pki/api/" + logicalPath + "/issue/" + roleName , & request , options )
0 commit comments