Skip to content

Commit a964ffd

Browse files
authored
Adds trusted CA certificate to solidfire backend
1 parent 87f527d commit a964ffd

File tree

6 files changed

+56
-31
lines changed

6 files changed

+56
-31
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
**
22
!bin/**
3+
!*.txt

operator/.dockerignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

operator/Dockerfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@ RUN mkdir /real-certs; \
88

99
FROM scratch
1010

11-
LABEL maintainers="The NetApp Trident Team" \
12-
app="trident-operator.netapp.io" description="Trident Operator"
11+
LABEL maintainer="The NetApp Trident Team" \
12+
app="trident-operator.netapp.io" \
13+
summary="Trident Operator" \
14+
description="Trident Operator manages the lifecycle of Trident instances in a Kubernetes cluster." \
15+
name="trident-operator" \
16+
vendor="NetApp, Inc." \
17+
version="25.06.0" \
18+
release="25.06.0"
1319

1420
ARG BIN=trident-operator
1521

1622
COPY --from=deps /real-certs/ /etc/ssl/certs/
23+
COPY NOTICE.txt NOTICE_ASUP_module.txt /licenses/
1724
COPY ${BIN} /trident-operator
1825

1926
ENTRYPOINT ["/trident-operator"]

storage_drivers/solidfire/api/api.go

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"bytes"
77
"context"
88
"crypto/tls"
9+
"crypto/x509"
10+
"encoding/base64"
911
"encoding/json"
1012
"fmt"
1113
"io"
@@ -32,20 +34,22 @@ type Client struct {
3234
DefaultBlockSize int64
3335
DebugTraceFlags map[string]bool
3436
AccountID int64
37+
httpClient *http.Client
3538
}
3639

3740
// Config holds the configuration data for the Client to communicate with a SolidFire storage system
3841
type Config struct {
39-
TenantName string
40-
EndPoint string
41-
MountPoint string
42-
SVIP string
43-
InitiatorIFace string // iface to use of iSCSI initiator
44-
Types *[]VolType
45-
LegacyNamePrefix string
46-
AccessGroups []int64
47-
DefaultBlockSize int64
48-
DebugTraceFlags map[string]bool
42+
TenantName string
43+
EndPoint string
44+
MountPoint string
45+
SVIP string
46+
InitiatorIFace string // iface to use of iSCSI initiator
47+
Types *[]VolType
48+
LegacyNamePrefix string
49+
AccessGroups []int64
50+
DefaultBlockSize int64
51+
DebugTraceFlags map[string]bool
52+
TrustedCACertificate string
4953
}
5054

5155
// VolType holds quality of service configuration data
@@ -56,6 +60,25 @@ type VolType struct {
5660

5761
// NewFromParameters is a factory method to create a new sfapi.Client object using the supplied parameters
5862
func NewFromParameters(pendpoint, psvip string, pcfg Config) (c *Client, err error) {
63+
tcfg := tls.Config{MinVersion: tridentconfig.MinClientTLSVersion, InsecureSkipVerify: true}
64+
if pcfg.TrustedCACertificate != "" {
65+
caCert, err := base64.StdEncoding.DecodeString(pcfg.TrustedCACertificate)
66+
if err != nil {
67+
return nil, err
68+
}
69+
caCertPool := x509.NewCertPool()
70+
if !caCertPool.AppendCertsFromPEM(caCert) {
71+
return nil, fmt.Errorf("failed to append CA certificate, certificate may be invalid or malformed")
72+
}
73+
tcfg.RootCAs = caCertPool
74+
tcfg.InsecureSkipVerify = false
75+
}
76+
httpClient := &http.Client{
77+
Transport: &http.Transport{
78+
TLSClientConfig: &tcfg,
79+
},
80+
Timeout: tridentconfig.StorageAPITimeoutSeconds * time.Second,
81+
}
5982
SFClient := &Client{
6083
Endpoint: pendpoint,
6184
SVIP: psvip,
@@ -64,6 +87,7 @@ func NewFromParameters(pendpoint, psvip string, pcfg Config) (c *Client, err err
6487
VolumeTypes: pcfg.Types,
6588
DefaultBlockSize: pcfg.DefaultBlockSize,
6689
DebugTraceFlags: pcfg.DebugTraceFlags,
90+
httpClient: httpClient,
6791
}
6892
return SFClient, nil
6993
}
@@ -104,14 +128,7 @@ func (c *Client) Request(ctx context.Context, method string, params interface{},
104128
c.Config.DebugTraceFlags["api"])
105129

106130
// Send the request
107-
tr := &http.Transport{
108-
TLSClientConfig: &tls.Config{InsecureSkipVerify: true, MinVersion: tridentconfig.MinClientTLSVersion},
109-
}
110-
httpClient := &http.Client{
111-
Transport: tr,
112-
Timeout: tridentconfig.StorageAPITimeoutSeconds * time.Second,
113-
}
114-
response, err = httpClient.Do(request)
131+
response, err = c.httpClient.Do(request)
115132
if err != nil {
116133
Logc(ctx).Errorf("Error response from SolidFire API request: %v", err)
117134
return nil, errors.New("device API error")

storage_drivers/solidfire/solidfire_san.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,16 @@ func (d *SANStorageDriver) Initialize(
201201
// Create a new api.Config object from the JSON config file
202202
svip := config.SVIP
203203
cfg := api.Config{
204-
TenantName: config.TenantName,
205-
EndPoint: endpoint,
206-
SVIP: config.SVIP,
207-
InitiatorIFace: config.InitiatorIFace,
208-
Types: config.Types,
209-
LegacyNamePrefix: config.LegacyNamePrefix,
210-
AccessGroups: config.AccessGroups,
211-
DefaultBlockSize: defaultBlockSize,
212-
DebugTraceFlags: config.DebugTraceFlags,
204+
TenantName: config.TenantName,
205+
EndPoint: endpoint,
206+
SVIP: config.SVIP,
207+
InitiatorIFace: config.InitiatorIFace,
208+
Types: config.Types,
209+
LegacyNamePrefix: config.LegacyNamePrefix,
210+
AccessGroups: config.AccessGroups,
211+
DefaultBlockSize: defaultBlockSize,
212+
DebugTraceFlags: config.DebugTraceFlags,
213+
TrustedCACertificate: config.TrustedCACertificate,
213214
}
214215

215216
Logc(ctx).WithFields(LogFields{

storage_drivers/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ type SolidfireStorageDriverConfig struct {
374374
AccessGroups []int64
375375
UseCHAP bool
376376
DefaultBlockSize int64 // blocksize to use on create when not specified (512|4096, 512 is default)
377+
TrustedCACertificate string
377378

378379
SolidfireStorageDriverPool
379380
Storage []SolidfireStorageDriverPool `json:"storage"`

0 commit comments

Comments
 (0)