ssl.connect now returns the result of the certificate validation.

This commit is contained in:
dom96
2010-10-23 23:35:47 +01:00
parent 293563ee11
commit beb9e3d325
2 changed files with 6 additions and 9 deletions

View File

@@ -17,12 +17,10 @@ type
ssl: PSSL
bio: PBIO
proc connect*(sock: var TSecureSocket, address: string,
port: int, certResult: var Int) =
port: int): Int =
## Connects to the specified `address` on the specified `port`.
## `certResult` will become the result of the certificate validation.
## Returns the result of the certificate validation.
SslLoadErrorStrings()
ERR_load_BIO_strings()
@@ -50,7 +48,7 @@ proc connect*(sock: var TSecureSocket, address: string,
ERR_print_errors_fp(stderr)
OSError()
certResult = SSL_get_verify_result(sock.ssl)
result = SSL_get_verify_result(sock.ssl)
proc recvLine*(sock: TSecureSocket, line: var String): bool =
## Acts in a similar fashion to the `recvLine` in the sockets module.

View File

@@ -24,7 +24,7 @@
## smtp.sendmail("username@gmail.com", @["foo@gmail.com"], $msg)
##
import sockets, strutils, strtabs, ssl, base64
import sockets, strutils, strtabs, ssl, base64, os
type
TSMTP* = object {.final.}
@@ -62,7 +62,7 @@ proc debugRecv(smtp: TSMTP): String =
echo("S:" & line)
return line
else:
echo("S-Warning: recvLine failed.")
OSError()
return ""
proc quitExcpt(smtp: TSMTP, msg: String) =
@@ -84,8 +84,7 @@ proc connect*(address: String, port: int = 25,
result.sock.connect(address, TPort(port))
else:
result.ssl = True
var certResult: int
result.sslSock.connect(address, port, certResult)
discard result.sslSock.connect(address, port)
result.debug = debug