@@ -21,6 +21,9 @@ namespace S7CommPlusDriver
2121 // | (at your option) any later version. |
2222 public class S7Client : OpenSSLConnector . IConnectorCallback
2323 {
24+ //TODO: better API, maybe a Callback
25+ public static bool WriteSslKeyToFile ;
26+
2427 #region [Constants and TypeDefs]
2528
2629 public int _LastError = 0 ;
@@ -120,7 +123,7 @@ public int SslActivate()
120123 {
121124 ret = Native . OPENSSL_init_ssl ( 0 , IntPtr . Zero ) ; // returns 1 on success or 0 on error
122125 if ( ret != 1 )
123- {
126+ {
124127 return S7Consts . errOpenSSL ;
125128 }
126129 m_ptr_ssl_method = Native . ExpectNonNull ( Native . TLS_client_method ( ) ) ;
@@ -132,20 +135,21 @@ public int SslActivate()
132135 Native . SSL_CTX_ctrl ( m_ptr_ctx , Native . SSL_CTRL_SET_MIN_PROTO_VERSION , Native . TLS1_3_VERSION , IntPtr . Zero ) ;
133136 ret = Native . SSL_CTX_set_ciphersuites ( m_ptr_ctx , "TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256" ) ;
134137 if ( ret != 1 )
135- {
138+ {
136139 return S7Consts . errOpenSSL ;
137140 }
138141 m_sslconn = new OpenSSLConnector ( m_ptr_ctx , this ) ;
139142 m_sslconn . ExpectConnect ( ) ;
140143
141144 // 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 ) ;
143147 Native . SSL_CTX_set_keylog_callback ( m_ptr_ctx , m_keylog_cb ) ;
144148
145149 m_SslActive = true ;
146150 }
147151 catch
148- {
152+ {
149153 return S7Consts . errOpenSSL ;
150154 }
151155 return 0 ;
@@ -284,7 +288,7 @@ public void Send(byte[] Buffer)
284288 }
285289
286290 private int SendIsoPacket ( byte [ ] Buffer )
287- {
291+ {
288292 // Packt die zu sendenden Daten in den Iso-Header ein.
289293 int Size = Buffer . Length ;
290294 _LastError = 0 ;
0 commit comments