diff options
Diffstat (limited to 'tests/stdlib/thttpclient_ssl.nim')
-rw-r--r-- | tests/stdlib/thttpclient_ssl.nim | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/tests/stdlib/thttpclient_ssl.nim b/tests/stdlib/thttpclient_ssl.nim index 71745c9df..6b963f029 100644 --- a/tests/stdlib/thttpclient_ssl.nim +++ b/tests/stdlib/thttpclient_ssl.nim @@ -1,5 +1,5 @@ discard """ - cmd: "nim $target --threads:on -d:ssl $options $file" + cmd: "nim $target --mm:refc -d:ssl $options $file" disabled: "openbsd" """ @@ -13,9 +13,12 @@ discard """ ## Test with: ## ./bin/nim c -d:ssl -p:. --threads:on -r tests/stdlib/thttpclient_ssl.nim -when not defined(windows): - # Disabled on Windows due to old OpenSSL version +from stdtest/testutils import disableSSLTesting + +when not defined(windows) and not disableSSLTesting(): + # Disabled on Windows due to old OpenSSL version + import std/[formatfloat, syncio] import httpclient, net, @@ -101,7 +104,7 @@ when not defined(windows): let t = spawn runServer(port) sleep(100) - var client = newHttpClient() + var client = newHttpClient(sslContext=newContext(verifyMode=CVerifyNone)) try: log "client: connect" discard client.getContent("https://127.0.0.1:12345") @@ -129,3 +132,19 @@ when not defined(windows): msg.contains("certificate verify failed")): echo "CVerifyPeer exception: " & msg check(false) + + test "HttpClient with CVerifyPeerUseEnvVars": + const port = 12346.Port + let t = spawn runServer(port) + sleep(100) + + putEnv("SSL_CERT_FILE", getCurrentDir() / certFile) + var client = newHttpClient(sslContext=newContext(verifyMode=CVerifyPeerUseEnvVars)) + try: + log "client: connect" + discard client.getContent("https://127.0.0.1:12346") + except: + let msg = getCurrentExceptionMsg() + log "client: exception: " & msg + log "getContent should not have raised an exception" + fail() |