Source Edit

OpenSSL wrapper. Supports OpenSSL >= 1.1.0 dynamically (as default) or statically linked using --dynlibOverride:ssl.

-d:sslVersion=1.2.3 can be used to force an SSL version. This version must be included in the library name. -d:useOpenssl3 may be set for OpenSSL 3 instead.

There is also limited support for OpenSSL 1.0.x which may require -d:openssl10.

Build and test examples:

  1. ./bin/nim c -d:ssl -p:. -r tests/stdlib/tssl.nim
  2. ./bin/nim c -d:ssl --threads:on -p:. -r tests/stdlib/thttpclient_ssl.nim
  3. ./bin/nim c -d:ssl -p:. -r tests/untestable/tssl.nim
  4. ./bin/nim c -d:ssl -p:. --dynlibOverride:ssl --passl:-lcrypto --passl:-lssl -r tests/untestable/tssl.nim
  5. ./bin/nim r --putenv:NIM_TESTAMENT_REMOTE_NETWORKING:1 -d:ssl -p:testament/lib --threads:on tests/untestable/thttpclient_ssl_remotenetwork.nim

Imports

strutils, winlean, dynlib, strutils

Types

  1. BIO = SslPtr

Source Edit

  1. DES_cblock = array[0 .. 7, int8]

Source Edit

  1. des_key_schedule = array[1 .. 16, des_ks_struct]

Source Edit

  1. des_ks_struct {.final.} = object
  2. ks*: DES_cblock
  3. weak_key*: cint

Source Edit

  1. ENGINE = SslPtr

Source Edit

  1. EVP_MD = SslPtr

Source Edit

  1. EVP_MD_CTX = SslPtr

Source Edit

  1. EVP_PKEY = SslPtr

Source Edit

  1. EVP_PKEY_CTX = SslPtr

Source Edit

  1. MD5_CTX = object

Source Edit

  1. MD5_LONG = cuint

Source Edit

  1. PaddingType = enum
  2. RSA_PKCS1_PADDING = 1, RSA_SSLV23_PADDING = 2, RSA_NO_PADDING = 3,
  3. RSA_PKCS1_OAEP_PADDING = 4, RSA_X931_PADDING = 5, RSA_PKCS1_PSS_PADDING = 6

Source Edit

  1. PASN1_cInt = SslPtr

Source Edit

  1. PASN1_UTCTIME = SslPtr

Source Edit

  1. PBIO_METHOD = SslPtr

Source Edit

  1. PDES_cblock = ptr DES_cblock

Source Edit

  1. pem_password_cb = proc (buf: cstring; size, rwflag: cint; userdata: pointer): cint {.
  2. cdecl.}

Source Edit

  1. PFunction = proc () {.cdecl.}

Source Edit

  1. PPasswdCb = SslPtr

Source Edit

  1. PRSA = SslPtr

Source Edit

  1. PskClientCallback = proc (ssl: SslPtr; hint: cstring; identity: cstring;
  2. max_identity_len: cuint; psk: ptr uint8;
  3. max_psk_len: cuint): cuint {.cdecl.}

Source Edit

  1. PskServerCallback = proc (ssl: SslPtr; identity: cstring; psk: ptr uint8;
  2. max_psk_len: cint): cuint {.cdecl.}

Source Edit

  1. PSSL_METHOD = SslPtr

Source Edit

  1. PSslPtr = ptr SslPtr

Source Edit

  1. PSTACK = SslPtr

Source Edit

  1. PX509 = SslPtr

Source Edit

  1. PX509_NAME = SslPtr

Source Edit

  1. SslCtx = SslPtr

Source Edit

  1. SslPtr = ptr SslStruct

Source Edit

Consts

  1. DLLSSLName = "(libssl-1_1-x64|ssleay64|libssl64).dll"

Source Edit

  1. DLLUtilName = "(libcrypto-1_1-x64|libeay64).dll"

Source Edit

  1. EVP_MAX_MD_SIZE = 36

Source Edit

  1. EVP_PKEY_RSA = 6

Source Edit

  1. MD5_CBLOCK = 64

Source Edit

  1. MD5_DIGEST_LENGTH = 16

Source Edit

  1. MD5_LBLOCK = 16

Source Edit

  1. OPENSSL_DES_DECRYPT = 0

Source Edit

  1. OPENSSL_DES_ENCRYPT = 1

Source Edit

  1. SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS = 11

Source Edit

  1. SSL_CTRL_EXTRA_CHAIN_CERT = 14

Source Edit

  1. SSL_CTRL_GET_CLIENT_CERT_REQUEST = 9

Source Edit

  1. SSL_CTRL_GET_FLAGS = 13

Source Edit

  1. SSL_CTRL_GET_MAX_CERT_LIST = 50

Source Edit

  1. SSL_CTRL_GET_NUM_RENEGOTIATIONS = 10

Source Edit

  1. SSL_CTRL_GET_READ_AHEAD = 40

Source Edit

  1. SSL_CTRL_GET_SESS_CACHE_MODE = 45

Source Edit

  1. SSL_CTRL_GET_SESS_CACHE_SIZE = 43

Source Edit

  1. SSL_CTRL_GET_SESSION_REUSED = 8

Source Edit

  1. SSL_CTRL_GET_TOTAL_RENEGOTIATIONS = 12

Source Edit

  1. SSL_CTRL_MODE = 33

Source Edit

  1. SSL_CTRL_NEED_TMP_RSA = 1

Source Edit

  1. SSL_CTRL_OPTIONS = 32

Source Edit

  1. SSL_CTRL_SESS_ACCEPT = 24

Source Edit

  1. SSL_CTRL_SESS_ACCEPT_GOOD = 25

Source Edit

  1. SSL_CTRL_SESS_ACCEPT_RENEGOTIATE = 26

Source Edit

  1. SSL_CTRL_SESS_CACHE_FULL = 31

Source Edit

  1. SSL_CTRL_SESS_CB_HIT = 28

Source Edit

  1. SSL_CTRL_SESS_CONNECT = 21

Source Edit

  1. SSL_CTRL_SESS_CONNECT_GOOD = 22

Source Edit

  1. SSL_CTRL_SESS_CONNECT_RENEGOTIATE = 23

Source Edit

  1. SSL_CTRL_SESS_HIT = 27

Source Edit

  1. SSL_CTRL_SESS_MISSES = 29

Source Edit

  1. SSL_CTRL_SESS_NUMBER = 20

Source Edit

  1. SSL_CTRL_SESS_TIMEOUTS = 30

Source Edit

  1. SSL_CTRL_SET_ECDH_AUTO = 94

Source Edit

  1. SSL_CTRL_SET_MAX_CERT_LIST = 51

Source Edit

  1. SSL_CTRL_SET_MSG_CALLBACK = 15

Source Edit

  1. SSL_CTRL_SET_MSG_CALLBACK_ARG = 16

Source Edit

  1. SSL_CTRL_SET_MTU = 17

Source Edit

  1. SSL_CTRL_SET_READ_AHEAD = 41

Source Edit

  1. SSL_CTRL_SET_SESS_CACHE_MODE = 44

Source Edit

  1. SSL_CTRL_SET_SESS_CACHE_SIZE = 42

Source Edit

  1. SSL_CTRL_SET_TMP_DH = 3

Source Edit

  1. SSL_CTRL_SET_TMP_DH_CB = 6

Source Edit

  1. SSL_CTRL_SET_TMP_ECDH = 4

Source Edit

  1. SSL_CTRL_SET_TMP_ECDH_CB = 7

Source Edit

  1. SSL_CTRL_SET_TMP_RSA = 2

Source Edit

  1. SSL_CTRL_SET_TMP_RSA_CB = 5

Source Edit

  1. SSL_ERROR_NONE = 0

Source Edit

  1. SSL_ERROR_SSL = 1

Source Edit

  1. SSL_ERROR_SYSCALL = 5

Source Edit

  1. SSL_ERROR_WANT_ACCEPT = 8

Source Edit

  1. SSL_ERROR_WANT_CONNECT = 7

Source Edit

  1. SSL_ERROR_WANT_READ = 2

Source Edit

  1. SSL_ERROR_WANT_WRITE = 3

Source Edit

  1. SSL_ERROR_WANT_X509_LOOKUP = 4

Source Edit

  1. SSL_ERROR_ZERO_RETURN = 6

Source Edit

  1. SSL_FILETYPE_ASN1 = 2

Source Edit

  1. SSL_FILETYPE_PEM = 1

Source Edit

  1. SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER = 2

Source Edit

  1. SSL_MODE_AUTO_RETRY = 4

Source Edit

  1. SSL_MODE_ENABLE_PARTIAL_WRITE = 1

Source Edit

  1. SSL_MODE_NO_AUTO_CHAIN = 8

Source Edit

  1. SSL_OP_ALL = 0x000FFFFF

Source Edit

  1. SSL_OP_NO_SSLv2 = 0x01000000

Source Edit

  1. SSL_OP_NO_SSLv3 = 0x02000000

Source Edit

  1. SSL_OP_NO_TLSv1 = 0x04000000

Source Edit

  1. SSL_OP_NO_TLSv1_1 = 0x08000000

Source Edit

  1. SSL_RECEIVED_SHUTDOWN = 2

Source Edit

  1. SSL_SENT_SHUTDOWN = 1

Source Edit

  1. SSL_ST_ACCEPT = 0x00002000

Source Edit

  1. SSL_ST_CONNECT = 0x00001000

Source Edit

  1. SSL_ST_INIT = 12288

Source Edit

  1. SSL_TLSEXT_ERR_ALERT_FATAL = 2

Source Edit

  1. SSL_TLSEXT_ERR_ALERT_WARNING = 1

Source Edit

  1. SSL_TLSEXT_ERR_NOACK = 3

Source Edit

  1. SSL_TLSEXT_ERR_OK = 0

Source Edit

  1. SSL_VERIFY_NONE = 0x00000000

Source Edit

  1. SSL_VERIFY_PEER = 0x00000001

Source Edit

  1. TLSEXT_NAMETYPE_host_name = 0

Source Edit

  1. useOpenssl3 {.booldefine.} = false

Source Edit

  1. X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH = 31

Source Edit

  1. X509_V_ERR_AKID_SKID_MISMATCH = 30

Source Edit

  1. X509_V_ERR_APPLICATION_VERIFICATION = 50

Source Edit

  1. X509_V_ERR_CERT_CHAIN_TOO_LONG = 22

Source Edit

  1. X509_V_ERR_CERT_HAS_EXPIRED = 10

Source Edit

  1. X509_V_ERR_CERT_NOT_YET_VALID = 9

Source Edit

  1. X509_V_ERR_CERT_REJECTED = 28

Source Edit

  1. X509_V_ERR_CERT_REVOKED = 23

Source Edit

  1. X509_V_ERR_CERT_SIGNATURE_FAILURE = 7

Source Edit

  1. X509_V_ERR_CERT_UNTRUSTED = 27

Source Edit

  1. X509_V_ERR_CRL_HAS_EXPIRED = 12

Source Edit

  1. X509_V_ERR_CRL_NOT_YET_VALID = 11

Source Edit

  1. X509_V_ERR_CRL_SIGNATURE_FAILURE = 8

Source Edit

  1. X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = 18

Source Edit

  1. X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = 14

Source Edit

  1. X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = 13

Source Edit

  1. X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD = 15

Source Edit

  1. X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = 16

Source Edit

  1. X509_V_ERR_INVALID_CA = 24

Source Edit

  1. X509_V_ERR_INVALID_PURPOSE = 26

Source Edit

  1. X509_V_ERR_KEYUSAGE_NO_CERTSIGN = 32

Source Edit

  1. X509_V_ERR_OUT_OF_MEM = 17

Source Edit

  1. X509_V_ERR_PATH_LENGTH_EXCEEDED = 25

Source Edit

  1. X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN = 19

Source Edit

  1. X509_V_ERR_SUBJECT_ISSUER_MISMATCH = 29

Source Edit

  1. X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY = 6

Source Edit

  1. X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE = 4

Source Edit

  1. X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE = 5

Source Edit

  1. X509_V_ERR_UNABLE_TO_GET_CRL = 3

Source Edit

  1. X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER = 33

Source Edit

  1. X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT = 2

Source Edit

  1. X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = 20

Source Edit

  1. X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE = 21

Source Edit

  1. X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION = 34

Source Edit

  1. X509_V_ILLEGAL = 1

Source Edit

  1. X509_V_OK = 0

Source Edit

Procs

  1. proc BIO_ctrl(bio: BIO; cmd: cint; larg: int; arg: cstring): int {.cdecl,
  2. dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc BIO_do_connect(bio: BIO): int {....raises: [], tags: [], forbids: [].}

Source Edit

  1. proc BIO_do_handshake(bio: BIO): int {....raises: [], tags: [], forbids: [].}

Source Edit

  1. proc BIO_free(b: BIO): cint {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc BIO_get_ssl(bio: BIO; ssl: ptr SslPtr): int {....raises: [], tags: [],
  2. forbids: [].}

Source Edit

  1. proc BIO_new_mem_buf(data: pointer; len: cint): BIO {.cdecl,
  2. dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc BIO_new_ssl_connect(ctx: SslCtx): BIO {.cdecl, dynlib: DLLSSLName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc BIO_read(b: BIO; data: cstring; length: cint): cint {.cdecl,
  2. dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc BIO_set_conn_hostname(bio: BIO; name: cstring): int {....raises: [], tags: [],
  2. forbids: [].}

Source Edit

  1. proc BIO_write(b: BIO; data: cstring; length: cint): cint {.cdecl,
  2. dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc bioCtrlPending(b: BIO): cint {.cdecl, dynlib: DLLUtilName,
  2. importc: "BIO_ctrl_pending", ...raises: [],
  3. tags: [], forbids: [].}

Source Edit

  1. proc bioFreeAll(b: BIO) {.cdecl, dynlib: DLLUtilName, importc: "BIO_free_all",
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc bioNew(b: PBIO_METHOD): BIO {.cdecl, dynlib: DLLUtilName,
  2. importc: "BIO_new", ...raises: [], tags: [],
  3. forbids: [].}

Source Edit

  1. proc bioRead(b: BIO; Buf: cstring; length: cint): cint {.cdecl,
  2. dynlib: DLLUtilName, importc: "BIO_read", ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc bioSMem(): PBIO_METHOD {.cdecl, dynlib: DLLUtilName, importc: "BIO_s_mem",
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc bioWrite(b: BIO; Buf: cstring; length: cint): cint {.cdecl,
  2. dynlib: DLLUtilName, importc: "BIO_write", ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc CRYPTO_malloc_init() {....raises: [], tags: [], forbids: [].}

Source Edit

  1. proc d2i_X509(b: string): PX509 {....raises: [Exception], tags: [], forbids: [].}

decode DER/BER bytestring into X.509 certificate struct Source Edit

  1. proc d2i_X509(px: ptr PX509; i: ptr ptr uint8; len: cint): PX509 {.cdecl,
  2. dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc ERR_error_string(e: culong; buf: cstring): cstring {.cdecl,
  2. dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc ERR_get_error(): culong {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc ERR_load_BIO_strings() {....raises: [Exception], tags: [RootEffect],
  2. forbids: [].}

Source Edit

  1. proc ERR_peek_last_error(): culong {.cdecl, dynlib: DLLUtilName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc ERR_print_errors_fp(fp: File) {.cdecl, dynlib: DLLUtilName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc ErrClearError() {.cdecl, dynlib: DLLUtilName, importc: "ERR_clear_error",
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc ErrFreeStrings() {.cdecl, dynlib: DLLUtilName, importc: "ERR_free_strings",
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc ErrRemoveState(pid: cint) {.cdecl, dynlib: DLLUtilName,
  2. importc: "ERR_remove_state", ...raises: [],
  3. tags: [], forbids: [].}

Source Edit

  1. proc EVP_DigestFinal_ex(ctx: EVP_MD_CTX; buffer: pointer; size: ptr cuint): cint {.
  2. cdecl, dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc EVP_DigestInit_ex(ctx: EVP_MD_CTX; typ: EVP_MD; engine: SslPtr = nil): cint {.
  2. cdecl, dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc EVP_DigestSignFinal(ctx: EVP_MD_CTX; data: pointer; len: ptr csize_t): cint {.
  2. cdecl, dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc EVP_DigestSignInit(ctx: EVP_MD_CTX; pctx: ptr EVP_PKEY_CTX; typ: EVP_MD;
  2. e: ENGINE; pkey: EVP_PKEY): cint {.cdecl,
  3. dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc EVP_DigestUpdate(ctx: EVP_MD_CTX; data: pointer; len: cuint): cint {.cdecl,
  2. dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc EVP_dss(): EVP_MD {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc EVP_dss1(): EVP_MD {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc EVP_ecdsa(): EVP_MD {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc EVP_md2(): EVP_MD {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc EVP_md4(): EVP_MD {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc EVP_md5(): EVP_MD {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc EVP_MD_CTX_cleanup(ctx: EVP_MD_CTX): cint {.cdecl, dynlib: DLLUtilName,
  2. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc EVP_MD_CTX_create(): EVP_MD_CTX {.cdecl, dynlib: DLLUtilName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc EVP_MD_CTX_destroy(ctx: EVP_MD_CTX) {.cdecl, dynlib: DLLUtilName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc EVP_md_null(): EVP_MD {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc EVP_MD_size(md: EVP_MD): cint {.cdecl, dynlib: DLLUtilName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc EVP_mdc2(): EVP_MD {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc EVP_PKEY_CTX_free(pkeyCtx: EVP_PKEY_CTX) {.cdecl, dynlib: DLLUtilName,
  2. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc EVP_PKEY_CTX_new(pkey: EVP_PKEY; e: ENGINE): EVP_PKEY_CTX {.cdecl,
  2. dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc EVP_PKEY_free(p: EVP_PKEY) {.cdecl, dynlib: DLLUtilName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc EVP_PKEY_sign_init(c: EVP_PKEY_CTX): cint {.cdecl, dynlib: DLLUtilName,
  2. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc EVP_ripemd160(): EVP_MD {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc EVP_sha(): EVP_MD {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc EVP_sha1(): EVP_MD {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc EVP_sha224(): EVP_MD {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc EVP_sha256(): EVP_MD {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc EVP_sha384(): EVP_MD {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc EVP_sha512(): EVP_MD {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc EVP_whirlpool(): EVP_MD {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc getOpenSSLVersion(): culong {....raises: [Exception], tags: [RootEffect],
  2. forbids: [].}

Return OpenSSL version as unsigned long or 0 if not available Source Edit

  1. proc HMAC(evp_md: EVP_MD; key: pointer; key_len: cint; d: cstring; n: csize_t;
  2. md: cstring; md_len: ptr cuint): cstring {.cdecl, dynlib: DLLUtilName,
  3. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc i2d_X509(cert: PX509): string {....raises: [Exception], tags: [], forbids: [].}

encode cert to DER string Source Edit

  1. proc i2d_X509(cert: PX509; o: ptr ptr uint8): cint {.cdecl, dynlib: DLLUtilName,
  2. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc md5(d: ptr uint8; n: csize_t; md: ptr uint8): ptr uint8 {.importc: "MD5",
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc md5_File(file: string): string {....raises: [IOError, Exception],
  2. tags: [ReadIOEffect], forbids: [].}

Generate MD5 hash for a file. Result is a 32 character Source Edit

  1. proc md5_Final(md: cstring; c: var MD5_CTX): cint {.importc: "MD5_Final",
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc md5_Init(c: var MD5_CTX): cint {.importc: "MD5_Init", ...raises: [], tags: [],
  2. forbids: [].}

Source Edit

  1. proc md5_Str(str: string): string {....raises: [], tags: [], forbids: [].}

Generate MD5 hash for a string. Result is a 32 character hex string with lowercase characters Source Edit

  1. proc md5_Transform(c: var MD5_CTX; b: ptr uint8) {.importc: "MD5_Transform",
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc md5_Update(c: var MD5_CTX; data: pointer; len: csize_t): cint {.
  2. importc: "MD5_Update", ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc OpenSSL_add_all_algorithms() {....raises: [LibraryError, Exception],
  2. tags: [RootEffect], forbids: [].}

Source Edit

  1. proc OPENSSL_config(configName: cstring) {.cdecl, dynlib: DLLUtilName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc OPENSSL_sk_num(stack: PSTACK): int {.cdecl, dynlib: DLLSSLName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc OPENSSL_sk_value(stack: PSTACK; index: int): pointer {.cdecl,
  2. dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc PEM_read_bio_PrivateKey(bp: BIO; x: ptr EVP_PKEY; cb: pointer; u: pointer): EVP_PKEY {.
  2. cdecl, dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc PEM_read_bio_RSA_PUBKEY(bp: BIO; x: ptr PRSA; pw: pem_password_cb;
  2. u: pointer): PRSA {.cdecl, dynlib: DLLUtilName,
  3. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc PEM_read_bio_RSAPrivateKey(bp: BIO; x: ptr PRSA; cb: pem_password_cb;
  2. u: pointer): PRSA {.cdecl, dynlib: DLLUtilName,
  3. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc PEM_read_bio_RSAPublicKey(bp: BIO; x: ptr PRSA; cb: pem_password_cb;
  2. u: pointer): PRSA {.cdecl, dynlib: DLLUtilName,
  3. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc PEM_read_RSA_PUBKEY(fp: pointer; x: ptr PRSA; cb: pem_password_cb;
  2. u: pointer): PRSA {.cdecl, dynlib: DLLUtilName,
  3. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc PEM_read_RSAPrivateKey(fp: pointer; x: ptr PRSA; cb: pem_password_cb;
  2. u: pointer): PRSA {.cdecl, dynlib: DLLUtilName,
  3. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc PEM_read_RSAPublicKey(fp: pointer; x: ptr PRSA; cb: pem_password_cb;
  2. u: pointer): PRSA {.cdecl, dynlib: DLLUtilName,
  3. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc RSA_free(rsa: PRSA) {.cdecl, dynlib: DLLUtilName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc RSA_private_decrypt(flen: cint; fr: ptr uint8; to: ptr uint8; rsa: PRSA;
  2. padding: PaddingType): cint {.cdecl,
  3. dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc RSA_private_encrypt(flen: cint; fr: ptr uint8; to: ptr uint8; rsa: PRSA;
  2. padding: PaddingType): cint {.cdecl,
  3. dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc RSA_public_decrypt(flen: cint; fr: ptr uint8; to: ptr uint8; rsa: PRSA;
  2. padding: PaddingType): cint {.cdecl,
  3. dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc RSA_public_encrypt(flen: cint; fr: ptr uint8; to: ptr uint8; rsa: PRSA;
  2. padding: PaddingType): cint {.cdecl,
  3. dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc RSA_size(rsa: PRSA): cint {.cdecl, dynlib: DLLUtilName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc RSA_verify(kind: cint; origMsg: pointer; origMsgLen: cuint;
  2. signature: pointer; signatureLen: cuint; rsa: PRSA): cint {.
  3. cdecl, dynlib: DLLUtilName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_accept(ssl: SslPtr): cint {.cdecl, dynlib: DLLSSLName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_connect(ssl: SslPtr): cint {.cdecl, dynlib: DLLSSLName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_ctrl(ssl: SslPtr; cmd: cint; larg: int; parg: pointer): int {.cdecl,
  2. dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_check_private_key(ctx: SslCtx): cint {.cdecl, dynlib: DLLSSLName,
  2. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_ctrl(ctx: SslCtx; cmd: cint; larg: clong; parg: pointer): clong {.
  2. cdecl, dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_free(arg0: SslCtx) {.cdecl, dynlib: DLLSSLName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_get_ex_data(ssl: SslCtx; idx: cint): pointer {.cdecl,
  2. dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_get_ex_new_index(argl: clong; argp: pointer; new_func: pointer;
  2. dup_func: pointer; free_func: pointer): cint {.
  3. cdecl, dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_load_verify_locations(ctx: SslCtx; CAfile: cstring; CApath: cstring): cint {.
  2. cdecl, dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_new(meth: PSSL_METHOD): SslCtx {.cdecl, dynlib: DLLSSLName,
  2. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_set_alpn_protos(ctx: SslCtx; protos: cstring; protos_len: cuint): cint {.
  2. cdecl, dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_set_alpn_select_cb(ctx: SslCtx; cb: proc (ssl: SslPtr;
  2. out_proto: ptr cstring; outlen: cstring; in_proto: cstring; inlen: cuint;
  3. arg: pointer): cint {.cdecl.}; arg: pointer): cint {.cdecl,
  4. dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_set_cipher_list(s: SslCtx; ciphers: cstring): cint {.cdecl,
  2. dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_set_ciphersuites(ctx: SslCtx; str: cstring): cint {.
  2. ...raises: [LibraryError, Exception], tags: [RootEffect], forbids: [].}

Source Edit

  1. proc SSL_CTX_set_ecdh_auto(ctx: SslCtx; onoff: cint): cint {.inline,
  2. ...raises: [Exception], tags: [RootEffect], forbids: [].}

Set automatic curve selection.

On OpenSSL >= 1.1.0 this is on by default and cannot be disabled.

Source Edit

  1. proc SSL_CTX_set_ex_data(ssl: SslCtx; idx: cint; arg: pointer): cint {.cdecl,
  2. dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_set_next_proto_select_cb(ctx: SslCtx; cb: proc (s: SslPtr;
  2. out_proto: cstring; outlen: cstring; in_proto: cstring; inlen: cuint;
  3. arg: pointer): cint {.cdecl.}; arg: pointer) {.cdecl, dynlib: DLLSSLName,
  4. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_set_next_protos_advertised_cb(ctx: SslCtx; cb: proc (ssl: SslPtr;
  2. out_proto: ptr cstring; outlen: ptr cuint; arg: pointer): cint {.cdecl.};
  3. arg: pointer) {.cdecl, dynlib: DLLSSLName, importc, ...raises: [], tags: [],
  4. forbids: [].}

Source Edit

  1. proc SSL_CTX_set_psk_client_callback(ctx: SslCtx; callback: PskClientCallback) {.
  2. cdecl, dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Set callback called when OpenSSL needs PSK (for client). Source Edit

  1. proc SSL_CTX_set_psk_server_callback(ctx: SslCtx; callback: PskServerCallback) {.
  2. cdecl, dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Set callback called when OpenSSL needs PSK (for server). Source Edit

  1. proc SSL_CTX_set_session_id_context(context: SslCtx; sid_ctx: string;
  2. sid_ctx_len: int) {.cdecl,
  3. dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_set_tlsext_servername_arg(ctx: SslCtx; arg: pointer): int {.
  2. ...raises: [], tags: [], forbids: [].}

Set the pointer to be used in the callback registered to SSL_CTX_set_tlsext_servername_callback. Source Edit

  1. proc SSL_CTX_set_tlsext_servername_callback(ctx: SslCtx;
  2. cb: proc (ssl: SslPtr; cb_id: int; arg: pointer): int {.cdecl.}): int {.
  3. ...raises: [], tags: [], forbids: [].}

Set the callback to be used on listening SSL connections when the client hello is received.

The callback should return one of:

  • SSL_TLSEXT_ERR_OK
  • SSL_TLSEXT_ERR_ALERT_WARNING
  • SSL_TLSEXT_ERR_ALERT_FATAL
  • SSL_TLSEXT_ERR_NOACK

Source Edit

  1. proc SSL_CTX_set_verify(s: SslCtx; mode: int;
  2. cb: proc (a: int; b: pointer): int {.cdecl.}) {.cdecl,
  3. dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_use_certificate_chain_file(ctx: SslCtx; filename: cstring): cint {.
  2. stdcall, dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_use_certificate_file(ctx: SslCtx; filename: cstring; typ: cint): cint {.
  2. stdcall, dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_use_PrivateKey_file(ctx: SslCtx; filename: cstring; typ: cint): cint {.
  2. cdecl, dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_CTX_use_psk_identity_hint(ctx: SslCtx; hint: cstring): cint {.cdecl,
  2. dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Set PSK identity hint to use. Source Edit

  1. proc SSL_free(ssl: SslPtr) {.cdecl, dynlib: DLLSSLName, importc, ...raises: [],
  2. tags: [], forbids: [].}

Source Edit

  1. proc SSL_get0_alpn_selected(ssl: SslPtr; data: ptr cstring; len: ptr cuint) {.
  2. cdecl, dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_get0_next_proto_negotiated(s: SslPtr; data: ptr cstring; len: ptr cuint) {.
  2. cdecl, dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_get0_verified_chain(ssl: SslPtr): PSTACK {.cdecl, dynlib: DLLSSLName,
  2. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_get_error(s: SslPtr; ret_code: cint): cint {.cdecl, dynlib: DLLSSLName,
  2. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_get_psk_identity(ssl: SslPtr): cstring {.cdecl, dynlib: DLLSSLName,
  2. importc, ...raises: [], tags: [], forbids: [].}

Get PSK identity. Source Edit

  1. proc SSL_get_servername(ssl: SslPtr; typ: cint = TLSEXT_NAMETYPE_host_name): cstring {.
  2. cdecl, dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Retrieve the server name requested in the client hello. This can be used in the callback set in SSL_CTX_set_tlsext_servername_callback to implement virtual hosting. May return nil. Source Edit

  1. proc SSL_get_shutdown(ssl: SslPtr): cint {.cdecl, dynlib: DLLSSLName,
  2. importc: "SSL_get_shutdown", ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_get_SSL_CTX(ssl: SslPtr): SslCtx {.cdecl, dynlib: DLLSSLName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_get_verify_result(ssl: SslPtr): int {.cdecl, dynlib: DLLSSLName,
  2. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_in_init(ssl: SslPtr): cint {....raises: [LibraryError, Exception],
  2. tags: [RootEffect], forbids: [].}

Source Edit

  1. proc SSL_library_init(): cint {.discardable, ...raises: [LibraryError, Exception],
  2. tags: [RootEffect], forbids: [].}

Initialize SSL using OPENSSL_init_ssl for OpenSSL >= 1.1.0 otherwise SSL_library_init Source Edit

  1. proc SSL_load_error_strings() {....raises: [LibraryError, Exception],
  2. tags: [RootEffect], forbids: [].}

Source Edit

  1. proc SSL_new(context: SslCtx): SslPtr {.cdecl, dynlib: DLLSSLName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_pending(ssl: SslPtr): cint {.cdecl, dynlib: DLLSSLName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_read(ssl: SslPtr; buf: pointer; num: int): cint {.cdecl,
  2. dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_select_next_proto(out_proto: ptr cstring; outlen: cstring;
  2. server: cstring; server_len: cuint; client: cstring;
  3. client_len: cuint): cint {.cdecl, dynlib: DLLSSLName,
  4. importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_set_alpn_protos(ssl: SslPtr; protos: cstring; protos_len: cuint): cint {.
  2. cdecl, dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_set_fd(ssl: SslPtr; fd: SocketHandle): cint {.cdecl,
  2. dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_set_shutdown(ssl: SslPtr; mode: cint) {.cdecl, dynlib: DLLSSLName,
  2. importc: "SSL_set_shutdown", ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_set_SSL_CTX(ssl: SslPtr; ctx: SslCtx): SslCtx {.cdecl,
  2. dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_set_tlsext_host_name(ssl: SslPtr; name: cstring): int {....raises: [],
  2. tags: [], forbids: [].}

Set the SNI server name extension to be used in a client hello. Returns 1 if SNI was set, 0 if current SSL configuration doesn’t support SNI. Source Edit

  1. proc SSL_shutdown(ssl: SslPtr): cint {.cdecl, dynlib: DLLSSLName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSL_write(ssl: SslPtr; buf: cstring; num: int): cint {.cdecl,
  2. dynlib: DLLSSLName, importc, ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSLCTXSetMode(ctx: SslCtx; mode: int): int {....raises: [], tags: [],
  2. forbids: [].}

Source Edit

  1. proc sslDoHandshake(ssl: SslPtr): cint {.cdecl, dynlib: DLLSSLName,
  2. importc: "SSL_do_handshake", ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc sslPeek(ssl: SslPtr; buf: cstring; num: cint): cint {.cdecl,
  2. dynlib: DLLSSLName, importc: "SSL_peek", ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc sslRead(ssl: SslPtr; buf: cstring; num: cint): cint {.cdecl,
  2. dynlib: DLLSSLName, importc: "SSL_read", ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc sslSetAcceptState(s: SslPtr) {.cdecl, dynlib: DLLSSLName,
  2. importc: "SSL_set_accept_state", ...raises: [],
  3. tags: [], forbids: [].}

Source Edit

  1. proc sslSetBio(ssl: SslPtr; rbio, wbio: BIO) {.cdecl, dynlib: DLLSSLName,
  2. importc: "SSL_set_bio", ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc sslSetConnectState(s: SslPtr) {.cdecl, dynlib: DLLSSLName,
  2. importc: "SSL_set_connect_state",
  3. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc SSLv2_method(): PSSL_METHOD {....raises: [LibraryError], tags: [RootEffect],
  2. forbids: [].}

Source Edit

  1. proc SSLv3_method(): PSSL_METHOD {....raises: [LibraryError], tags: [RootEffect],
  2. forbids: [].}

Source Edit

  1. proc SSLv23_client_method(): PSSL_METHOD {....raises: [LibraryError],
  2. tags: [RootEffect], forbids: [].}

Source Edit

  1. proc SSLv23_method(): PSSL_METHOD {....raises: [LibraryError], tags: [RootEffect],
  2. forbids: [].}

Source Edit

  1. proc sslWrite(ssl: SslPtr; buf: cstring; num: cint): cint {.cdecl,
  2. dynlib: DLLSSLName, importc: "SSL_write", ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc TLS_client_method(): PSSL_METHOD {....raises: [LibraryError],
  2. tags: [RootEffect], forbids: [].}

Source Edit

  1. proc TLS_method(): PSSL_METHOD {....raises: [LibraryError], tags: [RootEffect],
  2. forbids: [].}

Source Edit

  1. proc TLS_server_method(): PSSL_METHOD {....raises: [LibraryError],
  2. tags: [RootEffect], forbids: [].}

Source Edit

  1. proc TLSv1_method(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc,
  2. ...raises: [], tags: [], forbids: [].}

Source Edit