Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added security level mutator methods. #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions shim.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,14 @@ void X_OPENSSL_free(void *ref) {
OPENSSL_free(ref);
}

void X_SSL_set_security_level(SSL *ssl, int level) {
SSL_set_security_level(ssl, level);
}

int X_SSL_get_security_level(SSL *ssl) {
return SSL_get_security_level(ssl);
}

long X_SSL_set_options(SSL* ssl, long options) {
return SSL_set_options(ssl, options);
}
Expand Down
2 changes: 2 additions & 0 deletions shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ extern void X_OPENSSL_free(void *ref);
extern void *X_OPENSSL_malloc(size_t size);

/* SSL methods */
extern void X_SSL_set_security_level(SSL *ssl, int level);
extern int X_SSL_get_security_level(SSL *ssl);
extern long X_SSL_set_options(SSL* ssl, long options);
extern long X_SSL_get_options(SSL* ssl);
extern long X_SSL_clear_options(SSL* ssl, long options);
Expand Down
12 changes: 12 additions & 0 deletions ssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ func (s *SSL) GetServername() string {
return C.GoString(C.SSL_get_servername(s.ssl, C.TLSEXT_NAMETYPE_host_name))
}

// GetSecurityLevel gets the SSL security level. See
// https://www.openssl.org/docs/ssl/SSL_get_security_level.html
func (s *SSL) GetSecurityLevel() int {
return int(C.X_SSL_get_security_level(s.ssl))
}

// SetSecurityLevel sets the SSL security level. See
// https://www.openssl.org/docs/ssl/SSL_set_security_level.html
func (s *SSL) SetSecurityLevel(level int) {
C.X_SSL_set_security_level(s.ssl, C.int(level))
}

// GetOptions returns SSL options. See
// https://www.openssl.org/docs/ssl/SSL_CTX_set_options.html
func (s *SSL) GetOptions() Options {
Expand Down