2
2
3
3
import com .fasterxml .jackson .annotation .JsonInclude ;
4
4
import com .fasterxml .jackson .annotation .JsonProperty ;
5
+ import java .util .Optional ;
5
6
import lombok .Builder ;
6
7
import lombok .Value ;
7
8
8
- import java .util .Optional ;
9
-
10
9
/**
11
10
* TLS configuration for connecting to Flipt servers with custom certificates.
12
- *
11
+ *
13
12
* <p>This class provides comprehensive TLS configuration options including:
13
+ *
14
14
* <ul>
15
- * <li>Custom CA certificates for self-signed or private CAs</li>
16
- * <li>Client certificates for mutual TLS authentication</li>
17
- * <li>Certificate data as strings or file paths</li>
18
- * <li>Insecure mode for development (skip certificate verification)</li>
15
+ * <li>Custom CA certificates for self-signed or private CAs
16
+ * <li>Client certificates for mutual TLS authentication
17
+ * <li>Certificate data as strings or file paths
18
+ * <li>Insecure mode for development (skip certificate verification)
19
19
* </ul>
20
- *
20
+ *
21
21
* <p>Certificate data fields take precedence over file path fields when both are provided.
22
22
*/
23
23
@ Value
24
24
@ Builder
25
25
@ JsonInclude (JsonInclude .Include .NON_EMPTY )
26
26
public class TlsConfig {
27
27
28
- /**
29
- * Path to custom CA certificate file in PEM format.
30
- * Used to verify server certificates signed by custom or self-signed CAs.
31
- */
32
- @ JsonProperty ("ca_cert_file" )
33
- Optional <String > caCertFile ;
28
+ /**
29
+ * Path to custom CA certificate file in PEM format. Used to verify server certificates signed by
30
+ * custom or self-signed CAs.
31
+ */
32
+ @ JsonProperty ("ca_cert_file" )
33
+ Optional <String > caCertFile ;
34
34
35
- /**
36
- * Raw CA certificate content in PEM format.
37
- * Used to verify server certificates signed by custom or self-signed CAs.
38
- * Takes precedence over caCertFile when both are provided.
39
- */
40
- @ JsonProperty ("ca_cert_data" )
41
- Optional <String > caCertData ;
35
+ /**
36
+ * Raw CA certificate content in PEM format. Used to verify server certificates signed by custom
37
+ * or self-signed CAs. Takes precedence over caCertFile when both are provided.
38
+ */
39
+ @ JsonProperty ("ca_cert_data" )
40
+ Optional <String > caCertData ;
42
41
43
- /**
44
- * Skip certificate verification entirely.
45
- * <strong>WARNING:</strong> This should only be used in development environments.
46
- * Setting this to true makes connections vulnerable to man-in-the-middle attacks.
47
- */
48
- @ JsonProperty ("insecure_skip_verify" )
49
- Optional <Boolean > insecureSkipVerify ;
42
+ /**
43
+ * Skip certificate verification entirely. <strong>WARNING:</strong> This should only be used in
44
+ * development environments. Setting this to true makes connections vulnerable to
45
+ * man-in-the-middle attacks.
46
+ */
47
+ @ JsonProperty ("insecure_skip_verify" )
48
+ Optional <Boolean > insecureSkipVerify ;
50
49
51
- /**
52
- * Path to client certificate file in PEM format.
53
- * Used for mutual TLS authentication where the server requires client certificates.
54
- */
55
- @ JsonProperty ("client_cert_file" )
56
- Optional <String > clientCertFile ;
50
+ /**
51
+ * Path to client certificate file in PEM format. Used for mutual TLS authentication where the
52
+ * server requires client certificates.
53
+ */
54
+ @ JsonProperty ("client_cert_file" )
55
+ Optional <String > clientCertFile ;
57
56
58
- /**
59
- * Path to client private key file in PEM format.
60
- * Used for mutual TLS authentication where the server requires client certificates.
61
- * Must correspond to the clientCertFile.
62
- */
63
- @ JsonProperty ("client_key_file" )
64
- Optional <String > clientKeyFile ;
57
+ /**
58
+ * Path to client private key file in PEM format. Used for mutual TLS authentication where the
59
+ * server requires client certificates. Must correspond to the clientCertFile.
60
+ */
61
+ @ JsonProperty ("client_key_file" )
62
+ Optional <String > clientKeyFile ;
65
63
66
- /**
67
- * Raw client certificate content in PEM format.
68
- * Used for mutual TLS authentication where the server requires client certificates.
69
- * Takes precedence over clientCertFile when both are provided.
70
- */
71
- @ JsonProperty ("client_cert_data" )
72
- Optional <String > clientCertData ;
64
+ /**
65
+ * Raw client certificate content in PEM format. Used for mutual TLS authentication where the
66
+ * server requires client certificates. Takes precedence over clientCertFile when both are
67
+ * provided.
68
+ */
69
+ @ JsonProperty ("client_cert_data" )
70
+ Optional <String > clientCertData ;
73
71
74
- /**
75
- * Raw client private key content in PEM format.
76
- * Used for mutual TLS authentication where the server requires client certificates.
77
- * Must correspond to the clientCertData.
78
- * Takes precedence over clientKeyFile when both are provided.
79
- */
80
- @ JsonProperty ("client_key_data" )
81
- Optional <String > clientKeyData ;
72
+ /**
73
+ * Raw client private key content in PEM format. Used for mutual TLS authentication where the
74
+ * server requires client certificates. Must correspond to the clientCertData. Takes precedence
75
+ * over clientKeyFile when both are provided.
76
+ */
77
+ @ JsonProperty ("client_key_data" )
78
+ Optional <String > clientKeyData ;
82
79
83
- /**
84
- * Creates a TlsConfig for development with insecure certificate verification disabled.
85
- * <strong>WARNING:</strong> Only use this in development environments.
86
- *
87
- * @return TlsConfig with insecure skip verify enabled
88
- */
89
- public static TlsConfig insecure () {
90
- return TlsConfig .builder ()
91
- .insecureSkipVerify (Optional .of (true ))
92
- .build ();
93
- }
80
+ /**
81
+ * Creates a TlsConfig for development with insecure certificate verification disabled.
82
+ * <strong>WARNING:</strong> Only use this in development environments.
83
+ *
84
+ * @return TlsConfig with insecure skip verify enabled
85
+ */
86
+ public static TlsConfig insecure () {
87
+ return TlsConfig .builder ().insecureSkipVerify (Optional .of (true )).build ();
88
+ }
94
89
95
- /**
96
- * Creates a TlsConfig with a custom CA certificate from a file.
97
- *
98
- * @param caCertFile path to the CA certificate file in PEM format
99
- * @return TlsConfig with custom CA certificate
100
- */
101
- public static TlsConfig withCaCertFile (String caCertFile ) {
102
- return TlsConfig .builder ()
103
- .caCertFile (Optional .of (caCertFile ))
104
- .build ();
105
- }
90
+ /**
91
+ * Creates a TlsConfig with a custom CA certificate from a file.
92
+ *
93
+ * @param caCertFile path to the CA certificate file in PEM format
94
+ * @return TlsConfig with custom CA certificate
95
+ */
96
+ public static TlsConfig withCaCertFile (String caCertFile ) {
97
+ return TlsConfig .builder ().caCertFile (Optional .of (caCertFile )).build ();
98
+ }
106
99
107
- /**
108
- * Creates a TlsConfig with a custom CA certificate from string data.
109
- *
110
- * @param caCertData CA certificate content in PEM format
111
- * @return TlsConfig with custom CA certificate
112
- */
113
- public static TlsConfig withCaCertData (String caCertData ) {
114
- return TlsConfig .builder ()
115
- .caCertData (Optional .of (caCertData ))
116
- .build ();
117
- }
100
+ /**
101
+ * Creates a TlsConfig with a custom CA certificate from string data.
102
+ *
103
+ * @param caCertData CA certificate content in PEM format
104
+ * @return TlsConfig with custom CA certificate
105
+ */
106
+ public static TlsConfig withCaCertData (String caCertData ) {
107
+ return TlsConfig .builder ().caCertData (Optional .of (caCertData )).build ();
108
+ }
118
109
119
- /**
120
- * Creates a TlsConfig for mutual TLS with client certificate and key files.
121
- *
122
- * @param clientCertFile path to client certificate file in PEM format
123
- * @param clientKeyFile path to client private key file in PEM format
124
- * @return TlsConfig with mutual TLS configuration
125
- */
126
- public static TlsConfig withMutualTls (String clientCertFile , String clientKeyFile ) {
127
- return TlsConfig .builder ()
128
- .clientCertFile (Optional .of (clientCertFile ))
129
- .clientKeyFile (Optional .of (clientKeyFile ))
130
- .build ();
131
- }
110
+ /**
111
+ * Creates a TlsConfig for mutual TLS with client certificate and key files.
112
+ *
113
+ * @param clientCertFile path to client certificate file in PEM format
114
+ * @param clientKeyFile path to client private key file in PEM format
115
+ * @return TlsConfig with mutual TLS configuration
116
+ */
117
+ public static TlsConfig withMutualTls (String clientCertFile , String clientKeyFile ) {
118
+ return TlsConfig .builder ()
119
+ .clientCertFile (Optional .of (clientCertFile ))
120
+ .clientKeyFile (Optional .of (clientKeyFile ))
121
+ .build ();
122
+ }
132
123
133
- /**
134
- * Creates a TlsConfig for mutual TLS with client certificate and key data.
135
- *
136
- * @param clientCertData client certificate content in PEM format
137
- * @param clientKeyData client private key content in PEM format
138
- * @return TlsConfig with mutual TLS configuration
139
- */
140
- public static TlsConfig withMutualTlsData (String clientCertData , String clientKeyData ) {
141
- return TlsConfig .builder ()
142
- .clientCertData (Optional .of (clientCertData ))
143
- .clientKeyData (Optional .of (clientKeyData ))
144
- .build ();
145
- }
146
- }
124
+ /**
125
+ * Creates a TlsConfig for mutual TLS with client certificate and key data.
126
+ *
127
+ * @param clientCertData client certificate content in PEM format
128
+ * @param clientKeyData client private key content in PEM format
129
+ * @return TlsConfig with mutual TLS configuration
130
+ */
131
+ public static TlsConfig withMutualTlsData (String clientCertData , String clientKeyData ) {
132
+ return TlsConfig .builder ()
133
+ .clientCertData (Optional .of (clientCertData ))
134
+ .clientKeyData (Optional .of (clientKeyData ))
135
+ .build ();
136
+ }
137
+ }
0 commit comments