1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15+ using Keyfactor . PKI . X509 ;
1516using Newtonsoft . Json ;
16- using System . Collections . Generic ;
17+ using Newtonsoft . Json . Linq ;
18+ using System ;
19+ using System . Collections . Generic ;
20+
1721
1822namespace a10vthunder . Api . Models
1923{
@@ -31,47 +35,94 @@ public class ServerTemplateListResponse
3135 {
3236 [ JsonProperty ( "server-ssl-list" ) ]
3337 public List < ServerSslList > serverssllist { get ; set ; }
34- }
35-
36- public class ServerSslList
37- {
38- public string name { get ; set ; }
39-
40- [ JsonProperty ( "enable-tls-alert-logging" ) ]
41- public int enabletlsalertlogging { get ; set ; }
42-
43- [ JsonProperty ( "handshake-logging-enable" ) ]
44- public int handshakeloggingenable { get ; set ; }
45-
46- [ JsonProperty ( "session-key-logging-enable" ) ]
47- public int sessionkeyloggingenable { get ; set ; }
48-
49- [ JsonProperty ( "close-notify" ) ]
50- public int closenotify { get ; set ; }
51-
52- [ JsonProperty ( "session-ticket-enable" ) ]
53- public int sessionticketenable { get ; set ; }
54- public int version { get ; set ; }
55- public int dgversion { get ; set ; }
38+ }
39+
40+ public class ServerSslList
41+ {
42+ public string name { get ; set ; }
43+
44+ [ JsonProperty ( "enable-tls-alert-logging" ) ]
45+ public int enabletlsalertlogging { get ; set ; }
46+
47+ [ JsonProperty ( "handshake-logging-enable" ) ]
48+ public int handshakeloggingenable { get ; set ; }
49+
50+ [ JsonProperty ( "session-key-logging-enable" ) ]
51+ public int sessionkeyloggingenable { get ; set ; }
52+
53+ [ JsonProperty ( "close-notify" ) ]
54+ public int closenotify { get ; set ; }
55+
56+ [ JsonProperty ( "forward-proxy-enable" ) ]
57+ public int ? forwardproxyenable { get ; set ; } // optional
58+
59+ [ JsonProperty ( "session-ticket-enable" ) ]
60+ public int sessionticketenable { get ; set ; }
61+
62+ public int version { get ; set ; }
63+ public int dgversion { get ; set ; }
64+
65+ [ JsonProperty ( "ssli-logging" ) ]
66+ public int ? ssliLogging { get ; set ; } // optional
67+
68+ [ JsonProperty ( "ocsp-stapling" ) ]
69+ public int ocspstapling { get ; set ; }
70+
71+ [ JsonProperty ( "use-client-sni" ) ]
72+ public int useclientsni { get ; set ; }
73+
74+ [ JsonProperty ( "renegotiation-disable" ) ]
75+ public int renegotiationdisable { get ; set ; }
76+
77+ [ JsonProperty ( "session-cache-size" ) ]
78+ public int sessioncachesize { get ; set ; }
79+
80+ [ JsonProperty ( "early-data" ) ]
81+ public int earlydata { get ; set ; }
82+
83+ public string uuid { get ; set ; }
84+
85+ [ JsonProperty ( "certificate" ) ]
86+ [ JsonConverter ( typeof ( CertificateConverter ) ) ]
87+ public TemplateCertificate certificate { get ; set ; }
88+
89+ [ JsonProperty ( "cert" ) ]
90+ public string certFlat { get ; set ; }
91+
92+ [ JsonProperty ( "key" ) ]
93+ public string keyFlat { get ; set ; }
94+
95+ [ JsonProperty ( "a10-url" ) ]
96+ public string a10url { get ; set ; }
97+
98+ [ JsonIgnore ]
99+ public TemplateCertificate MergedCertificate => certificate ?? (
100+ certFlat != null && keyFlat != null
101+ ? new TemplateCertificate { cert = certFlat , key = keyFlat , uuid = uuid , a10url = a10url + "/certificate" }
102+ : null
103+ ) ;
104+ }
105+
106+ public class CertificateConverter : JsonConverter < TemplateCertificate >
107+ {
108+ public override TemplateCertificate ReadJson ( JsonReader reader , Type objectType , TemplateCertificate existingValue , bool hasExistingValue , JsonSerializer serializer )
109+ {
110+ JObject obj = JObject . Load ( reader ) ;
111+
112+ // Case 1: certificate is a full object
113+ if ( obj [ "cert" ] != null && obj [ "key" ] != null )
114+ {
115+ return obj . ToObject < TemplateCertificate > ( ) ;
116+ }
117+
118+ // If the certificate node is not an object (e.g., null or primitive), fallback
119+ return null ;
120+ }
121+
122+ public override void WriteJson ( JsonWriter writer , TemplateCertificate value , JsonSerializer serializer )
123+ {
124+ serializer . Serialize ( writer , value ) ;
125+ }
126+ }
56127
57- [ JsonProperty ( "ocsp-stapling" ) ]
58- public int ocspstapling { get ; set ; }
59-
60- [ JsonProperty ( "use-client-sni" ) ]
61- public int useclientsni { get ; set ; }
62-
63- [ JsonProperty ( "renegotiation-disable" ) ]
64- public int renegotiationdisable { get ; set ; }
65-
66- [ JsonProperty ( "session-cache-size" ) ]
67- public int sessioncachesize { get ; set ; }
68-
69- [ JsonProperty ( "early-data" ) ]
70- public int earlydata { get ; set ; }
71- public string uuid { get ; set ; }
72- public TemplateCertificate certificate { get ; set ; }
73-
74- [ JsonProperty ( "a10-url" ) ]
75- public string a10url { get ; set ; }
76- }
77128}
0 commit comments