-
Notifications
You must be signed in to change notification settings - Fork 2
/
xml_verify.go
42 lines (36 loc) · 930 Bytes
/
xml_verify.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package ncanode
type xmlVerifyRequest struct {
XML string `json:"xml"`
VerifyOCSP bool `json:"verifyOcsp"`
VerifyCRL bool `json:"verifyCrl"`
}
// XMLVerifyResponse describes json response from XMLVerify.
type XMLVerifyResponse struct {
apiResponse
Result struct {
Valid bool `json:"valid"`
Cert Cert `json:"cert"`
} `json:"result"`
}
// XMLVerify validates xml signature.
//
// See https://ncanode.kz/docs.php?go=50acb512216c279acfa7eeb6de6dc2592039bd83
func (c *Client) XMLVerify(xml string, verifyOCSP, verifyCRL bool) (*XMLVerifyResponse, error) {
if xml == "" {
return nil, ErrInvalidRequestBody
}
body := apiRequest{
Version: c.version,
Method: "XML.verify",
Params: xmlVerifyRequest{
XML: xml,
VerifyOCSP: verifyOCSP,
VerifyCRL: verifyCRL,
},
}
var reply XMLVerifyResponse
if err := c.call(body, &reply); err != nil {
return nil, err
}
return &reply, nil
}