Info sends an info request to the remote CFSSL server, receiving a response or an error in response. It takes the serialized JSON request to send.
(jsonData []byte)
| 253 | // response or an error in response. |
| 254 | // It takes the serialized JSON request to send. |
| 255 | func (srv *server) Info(jsonData []byte) (*info.Resp, error) { |
| 256 | res, err := srv.getResultMap(jsonData, "info") |
| 257 | if err != nil { |
| 258 | return nil, err |
| 259 | } |
| 260 | |
| 261 | info := new(info.Resp) |
| 262 | |
| 263 | if val, ok := res["certificate"]; ok { |
| 264 | info.Certificate = val.(string) |
| 265 | } |
| 266 | var usages []interface{} |
| 267 | if val, ok := res["usages"]; ok && val != nil { |
| 268 | usages = val.([]interface{}) |
| 269 | } |
| 270 | if val, ok := res["expiry"]; ok && val != nil { |
| 271 | info.ExpiryString = val.(string) |
| 272 | } |
| 273 | |
| 274 | info.Usage = make([]string, len(usages)) |
| 275 | for i, s := range usages { |
| 276 | info.Usage[i] = s.(string) |
| 277 | } |
| 278 | |
| 279 | return info, nil |
| 280 | } |
| 281 | |
| 282 | func (srv *server) getResultMap(jsonData []byte, target string) (result map[string]interface{}, err error) { |
| 283 | url := srv.getURL(target) |
nothing calls this directly
no test coverage detected