| 1 | module ssl |
| 2 | |
| 3 | $if tinyc && (freebsd || openbsd) { |
| 4 | import net.openssl |
| 5 | } $else { |
| 6 | import net.mbedtls |
| 7 | } |
| 8 | |
| 9 | $if tinyc && (freebsd || openbsd) { |
| 10 | // TinyCC hangs in the bundled mbedtls path on FreeBSD/OpenBSD. |
| 11 | // Prefer the OpenSSL backend there, which does not exhibit the issue. |
| 12 | pub type SSLConn = openssl.SSLConn |
| 13 | |
| 14 | @[params] |
| 15 | pub struct SSLConnectConfig { |
| 16 | openssl.SSLConnectConfig |
| 17 | } |
| 18 | |
| 19 | // new_ssl_conn returns a new SSLConn with the given config. |
| 20 | pub fn new_ssl_conn(config SSLConnectConfig) !&SSLConn { |
| 21 | return openssl.new_ssl_conn(config.SSLConnectConfig) or { return err } |
| 22 | } |
| 23 | } $else { |
| 24 | pub type SSLConn = mbedtls.SSLConn |
| 25 | |
| 26 | @[params] |
| 27 | pub struct SSLConnectConfig { |
| 28 | mbedtls.SSLConnectConfig |
| 29 | } |
| 30 | |
| 31 | // new_ssl_conn returns a new SSLConn with the given config. |
| 32 | pub fn new_ssl_conn(config SSLConnectConfig) !&SSLConn { |
| 33 | return mbedtls.new_ssl_conn(config.SSLConnectConfig) or { return err } |
| 34 | } |
| 35 | } |
| 36 | |