Skip to content

Commit

Permalink
Added SetReadAhead and made access to State work
Browse files Browse the repository at this point in the history
- SetReadAhead must be enabld for DTLS, though it is not clear why
- State write access is necessary for renegotiation started by the
  server, so that we can set the state to accept without mucking up the
  internal state of the SSL state machine, previous versions would cause
  unmanaged stack overflows
  • Loading branch information
David Wolinsky committed Nov 2, 2009
1 parent afec950 commit 9f33c78
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions ManagedOpenSsl/Core/Native.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2120,6 +2120,9 @@ public static int SSL_CTX_get_options(IntPtr ctx)
[DllImport(SSLDLLNAME)]
public extern static int SSL_state(IntPtr ssl);

[DllImport(SSLDLLNAME)]
public extern static void SSL_set_read_ahead(IntPtr ssl, int yes);

#endregion

#endregion
Expand Down
10 changes: 7 additions & 3 deletions ManagedOpenSsl/Ssl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ public SslState State
set
{
int offset = (int)Marshal.OffsetOf(typeof(ssl_st), "state");
IntPtr offset_ptr = new IntPtr((int)this.ptr + offset);
Marshal.WriteInt32(offset_ptr, (int) value);
Marshal.WriteInt32(this.ptr, offset, (int) value);
}
}

Expand Down Expand Up @@ -371,7 +370,7 @@ public int Renegotiate()

public int DoHandshake()
{
return Native.SSL_do_handshake(this.ptr);
return Native.SSL_do_handshake(this.ptr);
}

public void SetAcceptState()
Expand Down Expand Up @@ -404,6 +403,11 @@ public string StateStringLong()
return Marshal.PtrToStringAnsi(Native.SSL_state_string_long(this.ptr));
}

public void SetReadAhead(int yes)
{
Native.SSL_set_read_ahead(this.ptr, yes);
}

public int Clear()
{
return Native.ExpectSuccess(Native.SSL_clear(this.ptr));
Expand Down
3 changes: 1 addition & 2 deletions ManagedOpenSsl/SslContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ private struct SSL_CTX
public IntPtr default_verify_callback; //int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx)
public IntPtr generate_session_id; //typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id,unsigned int *id_len);
#region X509_VERIFY_PARAM
public IntPtr x509_verify_param_name;
public long x509_verify_param_check_time;
public IntPtr x509_verify_param_name; public long x509_verify_param_check_time;
public int x509_verify_param_inh_flags;
public int x509_verify_param_flags;
public int x509_verify_param_purpose;
Expand Down

0 comments on commit 9f33c78

Please sign in to comment.