-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprofile.go
53 lines (44 loc) · 1.51 KB
/
profile.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
53
package tmsh
import (
"fmt"
"strings"
)
// ClientSSLProffile contains information about Client SSL profile
type ClientSSLProfile struct {
Name string `ltm:"name"`
Component string `ltm:"component"`
Cert string `ltm:"cert"`
CertKeyChain map[string]map[string]string `ltm:"cert-key-chain"`
Chain string `ltm:"chain"`
DefaultsFrom string `ltm:"defaults-from"`
InheritCertkeychain bool `ltm:"inherit-certkeychain"`
Key string `ltm:"key"`
}
// GetAllClientSSLProfiles returns a list of all Client SSL Profiles
func (bigip *BigIP) GetAllClientSSLProfiles() ([]ClientSSLProfile, error) {
ret, err := bigip.ExecuteCommand("list ltm profile client-ssl")
if err != nil {
return nil, err
}
var profs []ClientSSLProfile
for _, p := range splitLtmOutput(ret) {
var prof ClientSSLProfile
if err := Unmarshal(p, &prof); err != nil {
return nil, err
}
profs = append(profs, prof)
}
return profs, nil
}
// GetClientSSLProfile gets a Client SSL Profile by name. Return nil if the profile does not found.
func (bigip *BigIP) GetClientSSLProfile(name string) (*ClientSSLProfile, error) {
ret, _ := bigip.ExecuteCommand("list ltm profile client-ssl " + name)
if strings.Contains(ret, "was not found.") {
return nil, fmt.Errorf(ret)
}
var prof ClientSSLProfile
if err := Unmarshal(ret, &prof); err != nil {
return nil, err
}
return &prof, nil
}