@@ -21,6 +21,9 @@ namespace S7CommPlusDriver
21
21
// | (at your option) any later version. |
22
22
public class S7Client : OpenSSLConnector . IConnectorCallback
23
23
{
24
+ //TODO: better API, maybe a Callback
25
+ public static bool WriteSslKeyToFile ;
26
+
24
27
#region [Constants and TypeDefs]
25
28
26
29
public int _LastError = 0 ;
@@ -120,7 +123,7 @@ public int SslActivate()
120
123
{
121
124
ret = Native . OPENSSL_init_ssl ( 0 , IntPtr . Zero ) ; // returns 1 on success or 0 on error
122
125
if ( ret != 1 )
123
- {
126
+ {
124
127
return S7Consts . errOpenSSL ;
125
128
}
126
129
m_ptr_ssl_method = Native . ExpectNonNull ( Native . TLS_client_method ( ) ) ;
@@ -132,20 +135,21 @@ public int SslActivate()
132
135
Native . SSL_CTX_ctrl ( m_ptr_ctx , Native . SSL_CTRL_SET_MIN_PROTO_VERSION , Native . TLS1_3_VERSION , IntPtr . Zero ) ;
133
136
ret = Native . SSL_CTX_set_ciphersuites ( m_ptr_ctx , "TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256" ) ;
134
137
if ( ret != 1 )
135
- {
138
+ {
136
139
return S7Consts . errOpenSSL ;
137
140
}
138
141
m_sslconn = new OpenSSLConnector ( m_ptr_ctx , this ) ;
139
142
m_sslconn . ExpectConnect ( ) ;
140
143
141
144
// Keylog callback setzen
142
- m_keylog_cb = new Native . SSL_CTX_keylog_cb_func ( SSL_CTX_keylog_cb ) ;
145
+ if ( WriteSslKeyToFile )
146
+ m_keylog_cb = new Native . SSL_CTX_keylog_cb_func ( SSL_CTX_keylog_cb ) ;
143
147
Native . SSL_CTX_set_keylog_callback ( m_ptr_ctx , m_keylog_cb ) ;
144
148
145
149
m_SslActive = true ;
146
150
}
147
151
catch
148
- {
152
+ {
149
153
return S7Consts . errOpenSSL ;
150
154
}
151
155
return 0 ;
@@ -284,7 +288,7 @@ public void Send(byte[] Buffer)
284
288
}
285
289
286
290
private int SendIsoPacket ( byte [ ] Buffer )
287
- {
291
+ {
288
292
// Packt die zu sendenden Daten in den Iso-Header ein.
289
293
int Size = Buffer . Length ;
290
294
_LastError = 0 ;
0 commit comments