SSL certificate verify GitHub action (#13697)
* Implement SSL/TLS certificate checking #782 * SSL: Add nimDisableCertificateValidation Remove NIM_SSL_CERT_VALIDATION env var tests/untestable/thttpclient_ssl.nim ran successfully on Linux with libssl 1.1.1d * SSL: update integ test to skip flapping tests * Revert .travis.yml change * nimDisableCertificateValidation disable imports Prevent loading symbols that are not defined on older SSL libs * SSL: disable verification in net.nim ..when nimDisableCertificateValidation is set * Update changelog * Fix peername type * Add define check for windows * Disable test on windows * Add exprimental GitHub action CI for SSL * Test nimDisableCertificateValidation
This commit is contained in:
parent
1d665adecd
commit
5b85444244
13 changed files with 872 additions and 12 deletions
40
tests/untestable/thttpclient_ssl_disabled.nim
Normal file
40
tests/untestable/thttpclient_ssl_disabled.nim
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#
|
||||
# Nim - SSL integration tests
|
||||
# (c) Copyright 2017 Nim contributors
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
## Warning: this test performs external networking.
|
||||
## Compile and run with:
|
||||
## ./bin/nim c -d:nimDisableCertificateValidation -d:ssl -r -p:. tests/untestable/thttpclient_ssl_disabled.nim
|
||||
|
||||
import httpclient,
|
||||
net,
|
||||
unittest,
|
||||
ospaths
|
||||
|
||||
from strutils import contains
|
||||
|
||||
const expired = "https://expired.badssl.com/"
|
||||
|
||||
doAssert defined(nimDisableCertificateValidation)
|
||||
|
||||
suite "SSL certificate check - disabled":
|
||||
|
||||
test "httpclient in insecure mode":
|
||||
var ctx = newContext(verifyMode = CVerifyPeer)
|
||||
var client = newHttpClient(sslContext = ctx)
|
||||
let a = $client.getContent(expired)
|
||||
|
||||
test "httpclient in insecure mode":
|
||||
var ctx = newContext(verifyMode = CVerifyPeerUseEnvVars)
|
||||
var client = newHttpClient(sslContext = ctx)
|
||||
let a = $client.getContent(expired)
|
||||
|
||||
test "net socket in insecure mode":
|
||||
var sock = newSocket()
|
||||
var ctx = newContext(verifyMode = CVerifyPeerUseEnvVars)
|
||||
ctx.wrapSocket(sock)
|
||||
sock.connect("expired.badssl.com", 443.Port)
|
||||
sock.close
|
||||
Loading…
Add table
Add a link
Reference in a new issue