With prior OpenSSL versions it was possible to do this in SWIG .i files:
STACK *ssl_get_ciphers(SSL *ssl) {
return (STACK *)SSL_get_ciphers(ssl);
}
With OpenSSL 1.0.0beta3 this fails because STACK seems to be no longer defined. New OpenSSL tries to do a better job at type checking, so one is supposed to use the STACK_OF macro, which is defined like this:
#define STACK_OF(type) struct stack_st_##type
If I change the code above to use STACK_OF:
STACK_OF(SSL_CIPHER) *ssl_get_ciphers(SSL *ssl) {
return SSL_get_ciphers(ssl);
}
Then SWIG does not like this:
Error: Syntax error in input(1).
I can get things to compile by changing that to:
struct stack_st_SSL_CIPHER *ssl_get_ciphers(SSL *ssl) {
return SSL_get_ciphers(ssl);
}
but this is obviously not good, because OpenSSL could change the macro from release to release. There is _STACK struct, but again that is OpenSSL private detail and could change from release to release. Stacks can also come in as parameters, as in:
int sk_x509_num(STACK_OF(X509) *stack) {
return sk_num(stack);
}
which SWIG does not like either.
Is there any way to make this work without resorting to using OpenSSL private details?