digitalmars.D.learn - HTTPS, SSL, TLS client on D
- Uranuz (9/9) Jan 28 2014 I continue to practice with web applications on D and I have some
- Andrea Fontana (7/16) Jan 29 2014 If your goal is to write web applications in D, probably you
- Uranuz (9/9) Jan 29 2014 In this case I want client programme on D that will communicate
- Andrea Fontana (3/12) Jan 29 2014 Did you missed this?
- Adam D. Ruppe (32/32) Jan 29 2014 You can also use OpenSSL. I wrote a little wrapper class that
- Uranuz (1/1) Jan 31 2014 Thanks for response. I think this would help with my problem.
I continue to practice with web applications on D and I have some questions about secure protocols of data transmissions. I don't have any experience with SSL/TLS so I need an advice how to get started. Is there any ready solution how to create client based on secured socket (for example HTTPS client). I would consider some existing C library with "good" interface. I was looking at libcurl but it looks confusing and couldn't make something that works. P.S. I would be glad for any useful advice
Jan 28 2014
On Wednesday, 29 January 2014 at 07:20:52 UTC, Uranuz wrote:I continue to practice with web applications on D and I have some questions about secure protocols of data transmissions. I don't have any experience with SSL/TLS so I need an advice how to get started. Is there any ready solution how to create client based on secured socket (for example HTTPS client). I would consider some existing C library with "good" interface. I was looking at libcurl but it looks confusing and couldn't make something that works. P.S. I would be glad for any useful adviceIf your goal is to write web applications in D, probably you should use a web-framework (like vibe.d) or a (fast/s)cgi interface over a well known server. In our company we use D for web applications using fastcgi with nginx and lightppd. It works fine, also with https that is managed by nginx itself.
Jan 29 2014
In this case I want client programme on D that will communicate with some server over secure HTTP. I want to be able to update DNS records via it's web API using web interface of my web application written on D. I could do it using some cross-site request on JavaScript XmlHTTPRequest, but I want to have some console utility too. HTTPS client written on D would be suitable but only obvious idea is to use libcurl. But it has slightly complicated C interface. Is there something simplier exists that you can advise?
Jan 29 2014
On Wednesday, 29 January 2014 at 09:07:18 UTC, Uranuz wrote:In this case I want client programme on D that will communicate with some server over secure HTTP. I want to be able to update DNS records via it's web API using web interface of my web application written on D. I could do it using some cross-site request on JavaScript XmlHTTPRequest, but I want to have some console utility too. HTTPS client written on D would be suitable but only obvious idea is to use libcurl. But it has slightly complicated C interface. Is there something simplier exists that you can advise?Did you missed this? http://dlang.org/phobos/std_net_curl.html
Jan 29 2014
You can also use OpenSSL. I wrote a little wrapper class that extends std.socket.Socket for it: https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/sslsocket.d If you download that file and compile it with your app: dmd yourfile.d sslsocket.d you should be able to import sslsocket. void main() { auto sock = new OpenSslSocket(AddressFamily.INET); sock.connect(new InternetAddress("localhost", 443)); sock.send("GET / HTTP/1.0\r\n\r\n"); import std.stdio; char[1024] buffer; writeln(buffer[0 .. sock.receive(buffer)]); } which gets from a local https server. Or of course you can connect to other things too and use the raw socket. If you want a wrapper library to do http, curl is one option phobos wrapper: http://dlang.org/phobos/std_net_curl.html my old wrapper: https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/curl.d the key function on mine is: string curl(string url, string data = null, string contentType = "application/x-www-form-urlencoded"); if you pass it a data string, it does a POST, otherwise it goes a GET on the url. I've also written non-curl http clients (see http.d and http2.d in my github), a http server (see cgi.d, it doesn't do ssl itself but you can put it behind apache or nginx or IIS to get it from them), and some oauth code (oauth.d in there). If you need to know anything about them feel free to ask.
Jan 29 2014
Thanks for response. I think this would help with my problem.
Jan 31 2014