@@ -464,12 +464,14 @@ type fn func(transport string, host string, username string,
464
464
password string , port int ) EapiConnectionEntity
465
465
466
466
// transports provides the method
467
+ // "https_certs" is also a transport method but it can't be found in the below map
468
+ // as it is separately handled through ConnectTLS.
469
+ // NewHTTPSCertsEapiConnection is the construtor method
467
470
var transports = map [string ]fn {
468
- "socket" : NewSocketEapiConnection ,
469
- "http_local" : NewHTTPLocalEapiConnection ,
470
- "http" : NewHTTPEapiConnection ,
471
- "https" : NewHTTPSEapiConnection ,
472
- "https_certs" : NewHTTPSCertsEapiConnection ,
471
+ "socket" : NewSocketEapiConnection ,
472
+ "http_local" : NewHTTPLocalEapiConnection ,
473
+ "http" : NewHTTPEapiConnection ,
474
+ "https" : NewHTTPSEapiConnection ,
473
475
}
474
476
475
477
// EapiConfig provides the instance for managing of eapi.conf file.
@@ -743,6 +745,10 @@ func ConnectTo(name string) (*Node, error) {
743
745
enablepwd := section ["enablepwd" ]
744
746
keyFile := section ["keyfile" ]
745
747
certFile := section ["certfile" ]
748
+
749
+ // CA Certificate file is optional
750
+ caCertFile := section ["cacertfile" ]
751
+
746
752
var port = UseDefaultPortNum
747
753
_ , ok := section ["port" ]
748
754
if ok {
@@ -751,7 +757,7 @@ func ConnectTo(name string) (*Node, error) {
751
757
var node * Node
752
758
var err error
753
759
if transport == "https_certs" {
754
- node , err = ConnectTLS (transport , host , keyFile , certFile , port )
760
+ node , err = ConnectTLS (transport , host , keyFile , certFile , caCertFile , port )
755
761
} else {
756
762
node , err = Connect (transport , host , username , passwd , port )
757
763
}
@@ -801,8 +807,8 @@ func Connect(transport string, host string, username string, passwd string,
801
807
return node , nil
802
808
}
803
809
804
- func ConnectTLS (transport string , host string , keyFile string , certFile string , port int ) (* Node , error ) {
805
- conn , err := ConnectionTLS (transport , host , keyFile , certFile , port )
810
+ func ConnectTLS (transport , host , keyFile , certFile , caCertFile string , port int ) (* Node , error ) {
811
+ conn , err := ConnectionTLS (transport , host , keyFile , certFile , caCertFile , port )
806
812
if err != nil {
807
813
return nil , err
808
814
}
@@ -859,8 +865,8 @@ func Connection(transport string, host string, username string, passwd string,
859
865
return obj , nil
860
866
}
861
867
862
- func ConnectionTLS (transport string , host string , keyFile string , certFile string , port int ) (EapiConnectionEntity , error ) {
863
- obj := NewHTTPSCertsEapiConnection (transport , host , keyFile , certFile , port )
868
+ func ConnectionTLS (transport , host , keyFile , certFile , caCertFile string , port int ) (EapiConnectionEntity , error ) {
869
+ obj := NewHTTPSCertsEapiConnection (transport , host , keyFile , certFile , caCertFile , port )
864
870
return obj , nil
865
871
}
866
872
0 commit comments