thttpclient_ssl_disabled.nim 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #
  2. # Nim - SSL integration tests
  3. # (c) Copyright 2017 Nim contributors
  4. #
  5. # See the file "copying.txt", included in this
  6. # distribution, for details about the copyright.
  7. #
  8. ## Compile and run with:
  9. ## nim r --putenv:NIM_TESTAMENT_REMOTE_NETWORKING:1 -d:nimDisableCertificateValidation -d:ssl -p:. tests/untestable/thttpclient_ssl_disabled.nim
  10. from stdtest/testutils import enableRemoteNetworking
  11. # badssl tests disabled indefinitely
  12. when false and enableRemoteNetworking and (defined(nimTestsEnableFlaky) or not defined(openbsd)):
  13. import httpclient, net, unittest
  14. const expired = "https://expired.badssl.com/"
  15. doAssert defined(nimDisableCertificateValidation)
  16. suite "SSL certificate check - disabled":
  17. test "httpclient in insecure mode":
  18. var ctx = newContext(verifyMode = CVerifyPeer)
  19. var client = newHttpClient(sslContext = ctx)
  20. let a = $client.getContent(expired)
  21. test "httpclient in insecure mode":
  22. var ctx = newContext(verifyMode = CVerifyPeerUseEnvVars)
  23. var client = newHttpClient(sslContext = ctx)
  24. let a = $client.getContent(expired)
  25. test "net socket in insecure mode":
  26. var sock = newSocket()
  27. var ctx = newContext(verifyMode = CVerifyPeerUseEnvVars)
  28. ctx.wrapSocket(sock)
  29. sock.connect("expired.badssl.com", 443.Port)
  30. sock.close