-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
52 lines (44 loc) · 1.22 KB
/
main.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
43
44
45
46
47
48
49
50
51
52
package main
import (
"context"
"encoding/json"
"fmt"
"github.com/Keyfactor/ejbca-go-client-sdk/api/ejbca"
"log"
"strings"
)
func main() {
configuration := ejbca.NewConfiguration()
configuration.Debug = false
apiClient, err := ejbca.NewAPIClient(configuration)
if err != nil {
bad, ok := err.(*ejbca.GenericOpenAPIError)
if ok {
fmt.Printf("Error: %s", string(bad.Body()))
}
log.Fatal(err)
}
exclude := []string{
"ACMECONFIG:*;CRYPTOTOKEN:*",
}
include := []string{
"CERTPROFILE:*",
}
_, httpResp, err := apiClient.V1ConfigdumpApi.GetJsonConfigdump(context.Background()).Ignoreerrors(true).Exclude(exclude).Include(include).Execute()
if !strings.Contains(err.Error(), "json: cannot unmarshal object into Go value of type []string") {
bad, ok := err.(*ejbca.GenericOpenAPIError)
if ok {
fmt.Printf("Error: %s", string(bad.Body()))
}
log.Fatal(err)
}
var configDump interface{} // Decode JSON body
err = json.NewDecoder(httpResp.Body).Decode(&configDump)
if err != nil {
log.Fatal(err)
}
eepMap := configDump.(map[string]interface{})["end-entity-profiles"]
for key, mapValue := range eepMap.(map[string]interface{}) {
fmt.Printf("End entity profile %s has value:\n%v\n\n", key, mapValue)
}
}