getting an SSL connection to work

2020-08-18 Thread JohnAD
I've narrowed it down quite a bit: import net # proc mainAsync() {.async.} = # var ctx = newContext() # var next_socket = newAsyncSocket() # wrapSocket(ctx, next_socket) # await next_socket.connect("google.com", Port(443)) # await next_

getting an SSL connection to work

2020-08-18 Thread JohnAD
@dom96 What fixed it in the end was using the async methods. Apparently the non-async method is broken in some way. So, the following does appear to work. import asyncnet, net, asyncdispatch proc main() {.async.} = var ctx = newContext() var next_socket = newAs

getting an SSL connection to work

2020-08-18 Thread dom96
> Your example does not list them but I trust you're performing those steps? You do not need to perform this initialisation! It is done for you by the stdlib implicitly if `-d:ssl` is passed to the compiler.

getting an SSL connection to work

2020-08-18 Thread dom96
I don't see what the error in your code is @JohnAD. Is this a bug caused by the new SSL changes? (Does it work in 1.0?) Is the problem that a new SSL context isn't created? @federico3 if this is a programmer bug then we shouldn't be crashing in such a confusing way. Can this be improved?

getting an SSL connection to work

2020-08-18 Thread federico3
Indeed the documentation in [https://nim-lang.org/docs/httpclient.html#sslslashtls-support](https://nim-lang.org/docs/httpclient.html#sslslashtls-support) should be improved Documentation on setting the SSL context is available at [https://nim-lang.org/docs/net.html#newContext%2Cstring%2Cstring

getting an SSL connection to work

2020-08-18 Thread enthus1ast
This example was working a few months ago [https://github.com/enthus1ast/nimSslExample](https://github.com/enthus1ast/nimSslExample) This also shows how a way to get self signed certificates working (not the best way imho)

getting an SSL connection to work

2020-08-17 Thread lucian
The listed error kind of points to a failed SSL handshake. AFAIK, openssl requires some basic initilisaton steps. . Your example does not list them but I trust you're performing those steps? import net, openssl SSL_library_init() OpenSSL_add_all_algorithms() #

getting an SSL connection to work

2020-08-17 Thread JohnAD
lum, Thanks for the help! My example is somewhat misleading as I was just trying to make a short and easy to read example of the problem. So I chose a simple web connection. I agree with you, if I was trying to reach a web server or any server that used a web api, **httpClient** would be the w

getting an SSL connection to work

2020-08-17 Thread JohnAD
My machine has `OpenSSL 1.1.1f 31 Mar 2020` installed on it. I find no references to `libressl`. And, I see the following libs: ./usr/lib/i386-linux-gnu/libssl.so.1.1 ./usr/lib/x86_64-linux-gnu/libssl.so.1.1 Run Is openssl problematic? I see a "nimssl" package in

getting an SSL connection to work

2020-08-17 Thread lum
You can also use **httpClient** (stdlib) for this: import httpClient let client = newHttpClient() var content = client.getContent("https://google.com";) Run If you want to send custom https request use this: import httpclient, json

getting an SSL connection to work

2020-08-16 Thread treeform
I had countless issues with Ubuntu SSL, this does not surprise me. It's probably dynamically linking with the wrong installed SSL. I would delete all SSL versions but the most resent ones. Can you list the SSL versions you have installed? Is it openssl or libressl?

getting an SSL connection to work

2020-08-16 Thread JohnAD
Not to say anything silly like "Nim needs more published examples". :) I'm writing an SSL client and and having some difficulties. Rather than posting the complex version, I've written a simplified example of a client that simply sends a string to a website in the sky: import net