tssl.nim 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. ## Warning: this test performs external networking.
  9. ##
  10. ## Test with:
  11. ## ./bin/nim c -d:ssl -p:. -r tests/untestable/tssl.nim
  12. ## ./bin/nim c -d:ssl -p:. --dynlibOverride:ssl --passL:-lcrypto --passL:-lssl -r tests/untestable/tssl.nim
  13. ## The compilation is expected to succeed with any new/old version of OpenSSL,
  14. ## both with dynamic and static linking.
  15. ## The "howsmyssl" test is known to fail with OpenSSL < 1.1 due to insecure
  16. ## cypher suites being used.
  17. import httpclient, os
  18. from strutils import contains, toHex
  19. from openssl import getOpenSSLVersion
  20. when true:
  21. echo "version: 0x" & $getOpenSSLVersion().toHex()
  22. let client = newHttpClient()
  23. # hacky SSL check
  24. const url = "https://www.howsmyssl.com"
  25. let report = client.getContent(url)
  26. if not report.contains(">Probably Okay</span>"):
  27. let fn = getTempDir() / "sslreport.html"
  28. echo "SSL CHECK ERROR, see " & fn
  29. writeFile(fn, report)
  30. quit(1)
  31. echo "done"