digitalmars.D.learn - How to curl!
- IntegratedDimensions (28/28) May 01 2018 Trying to curl basic stuff but std.net.curl isn't cooperating:
- Dr.No (4/8) May 01 2018 Just a wild guess, do you have the SSL dlls in the same folder as
- IntegratedDimensions (7/17) May 01 2018 What SSL dlls? I'm sure they would be installed with whatever
- Dr.No (15/33) May 01 2018 those dlls:
- IntegratedDimensions (5/24) May 01 2018 I don't think this is the problem.
- Arun Chandrasekaran (7/11) May 01 2018 std.net.curl is not quite up to date when compared to the curl
- IntegratedDimensions (9/20) May 01 2018 Ok, first try:
- ikod (3/23) May 01 2018 Did you try to use full path to cacert.pem?
- IntegratedDimensions (3/21) May 02 2018 That seemed to work. Why would it not look in the current
- ikod (9/31) May 02 2018 Not sure about curl, but dlang-requests just pass filename as-is
Trying to curl basic stuff but std.net.curl isn't cooperating: curl "https://www.googleapis.com/youtube/v3/channels" -G -d part=contentDetails -d forUsername=test -d key=somekey import std.stdio; import std.net.curl; int main(string[] argv) { auto http = HTTP(); http.caInfo("cacert.pem"); // cacert.pem installed in the bin dir http.handle.set(CurlOption.ssl_verifypeer, 1); auto content = post("https://www.googleapis.com/youtube/v3/channels", ["part" : "contentDetails", "forUsername" : "test", "key" : "somekey"], http); return 0; } I either get the error Unhandled exception: std.net.curl.CurlException Peer certificate cannot be authenticated with given CA certificates on handle at std\net\curl.d(4343) or, when verifypeer is 0, Unhandled exception: std.net.curl.HTTPStatusException HTTP request returned status code 404 (Not Found) But the command line version works fine. (of course, if you want to test you must use a valid key and youtube user name. This is one of the reasons I hate D ;/ I've spent more time trying to get std.net.curl to do something that just works from the command line.
May 01 2018
On Tuesday, 1 May 2018 at 21:57:22 UTC, IntegratedDimensions wrote:Trying to curl basic stuff but std.net.curl isn't cooperating: curl "https://www.googleapis.com/youtube/v3/channels" -G -d part=contentDetails -d forUsername=test -d key=somekey [...]Just a wild guess, do you have the SSL dlls in the same folder as your executable or (less likely) in your PATH?
May 01 2018
On Tuesday, 1 May 2018 at 22:08:50 UTC, Dr.No wrote:On Tuesday, 1 May 2018 at 21:57:22 UTC, IntegratedDimensions wrote:What SSL dlls? I'm sure they would be installed with whatever installation uses them. ssleay32.dll comes with dmd2 and it is in the path, if that is what you are talking about. If a dll was missing though and that was the problem then it needs to state that it is a missing dll rather than some other issue.Trying to curl basic stuff but std.net.curl isn't cooperating: curl "https://www.googleapis.com/youtube/v3/channels" -G -d part=contentDetails -d forUsername=test -d key=somekey [...]Just a wild guess, do you have the SSL dlls in the same folder as your executable or (less likely) in your PATH?
May 01 2018
On Tuesday, 1 May 2018 at 22:51:01 UTC, IntegratedDimensions wrote:On Tuesday, 1 May 2018 at 22:08:50 UTC, Dr.No wrote:those dlls: libeay32.dll libssl32.dll ssleay32.dll I'm sure they would be installed with whateverOn Tuesday, 1 May 2018 at 21:57:22 UTC, IntegratedDimensions wrote:What SSL dlls?Trying to curl basic stuff but std.net.curl isn't cooperating: curl "https://www.googleapis.com/youtube/v3/channels" -G -d part=contentDetails -d forUsername=test -d key=somekey [...]Just a wild guess, do you have the SSL dlls in the same folder as your executable or (less likely) in your PATH?installation uses them.I don't think so. IIRC, when I used D+curl I needed to download them manutally. This is always the case with Qt. Even using windeployqt with --webkit2 flag I still need to copy those dlls to application binary folder.ssleay32.dll comes with dmd2 and it is in the path, if that is what you are talking about. If a dll was missing though and that was the problem then it needs to state that it is a missing dll rather than some other issue.It isn't always the case if the dll is dynamic loaded, it might fail quietly, for example, if you deploy an Qt application with QWebKit missing those Open SSL dlls, an page with https protocol just doesn't open and didn't show any error at all. To find out whether some referenced dll by your executable is missing, people use Dependence Walker: http://www.dependencywalker.com/
May 01 2018
On Tuesday, 1 May 2018 at 23:02:39 UTC, Dr.No wrote:On Tuesday, 1 May 2018 at 22:51:01 UTC, IntegratedDimensions wrote:I don't think this is the problem. If I use get on https://www.google.com it works fine but if I use get on https://www.googleapis.com/youtube/v3/channels it fails so it is site dependent.[...]those dlls: libeay32.dll libssl32.dll ssleay32.dll I'm sure they would be installed with whatever[...]I don't think so. IIRC, when I used D+curl I needed to download them manutally. This is always the case with Qt. Even using windeployqt with --webkit2 flag I still need to copy those dlls to application binary folder.[...]It isn't always the case if the dll is dynamic loaded, it might fail quietly, for example, if you deploy an Qt application with QWebKit missing those Open SSL dlls, an page with https protocol just doesn't open and didn't show any error at all. To find out whether some referenced dll by your executable is missing, people use Dependence Walker: http://www.dependencywalker.com/
May 01 2018
On Tuesday, 1 May 2018 at 21:57:22 UTC, IntegratedDimensions wrote:Trying to curl basic stuff but std.net.curl isn't cooperating: This is one of the reasons I hate D ;/ I've spent more time trying to get std.net.curl to do something that just works from the command line.std.net.curl is not quite up to date when compared to the curl command. It is not useful any non-trivial stuff. Right now I'm using ikod's dlang-requests[1] and I'm quite happy with it. I would recommend you to try it. [1] https://github.com/ikod/dlang-requests
May 01 2018
On Tuesday, 1 May 2018 at 23:35:42 UTC, Arun Chandrasekaran wrote:On Tuesday, 1 May 2018 at 21:57:22 UTC, IntegratedDimensions wrote:Ok, first try: Unhandled exception: object.Exception can't complete call to TLS_method at requests\ssl_adapter.d(248) which says it can't find the lib. I renamed ssleay32.dll to libssl32.dll and it then passed. I am getting http 404 error though ;/ I turned off cert though, which may be the reason, I have no idea. Seems to be working through.Trying to curl basic stuff but std.net.curl isn't cooperating: This is one of the reasons I hate D ;/ I've spent more time trying to get std.net.curl to do something that just works from the command line.std.net.curl is not quite up to date when compared to the curl command. It is not useful any non-trivial stuff. Right now I'm using ikod's dlang-requests[1] and I'm quite happy with it. I would recommend you to try it. [1] https://github.com/ikod/dlang-requests
May 01 2018
On Wednesday, 2 May 2018 at 00:04:49 UTC, IntegratedDimensions wrote:On Tuesday, 1 May 2018 at 23:35:42 UTC, Arun Chandrasekaran wrote:Did you try to use full path to cacert.pem?On Tuesday, 1 May 2018 at 21:57:22 UTC, IntegratedDimensions wrote:Ok, first try: Unhandled exception: object.Exception can't complete call to TLS_method at requests\ssl_adapter.d(248) which says it can't find the lib. I renamed ssleay32.dll to libssl32.dll and it then passed. I am getting http 404 error though ;/ I turned off cert though, which may be the reason, I have no idea. Seems to be working through.[...]std.net.curl is not quite up to date when compared to the curl command. It is not useful any non-trivial stuff. Right now I'm using ikod's dlang-requests[1] and I'm quite happy with it. I would recommend you to try it. [1] https://github.com/ikod/dlang-requests
May 01 2018
On Wednesday, 2 May 2018 at 03:03:19 UTC, ikod wrote:On Wednesday, 2 May 2018 at 00:04:49 UTC, IntegratedDimensions wrote:That seemed to work. Why would it not look in the current directory by default? Maybe something to add?On Tuesday, 1 May 2018 at 23:35:42 UTC, Arun Chandrasekaran wrote:Did you try to use full path to cacert.pem?[...]Ok, first try: Unhandled exception: object.Exception can't complete call to TLS_method at requests\ssl_adapter.d(248) which says it can't find the lib. I renamed ssleay32.dll to libssl32.dll and it then passed. I am getting http 404 error though ;/ I turned off cert though, which may be the reason, I have no idea. Seems to be working through.
May 02 2018
On Wednesday, 2 May 2018 at 16:58:35 UTC, IntegratedDimensions wrote:On Wednesday, 2 May 2018 at 03:03:19 UTC, ikod wrote:Not sure about curl, but dlang-requests just pass filename as-is to libssl. I think that if you have cert file in current directiry, and use no path in call to sslSetCertFile it should work. If not - please post bugreport to github.com/ikod/dlang-requests PS. I'll check and add ssleay32 to search names for dynamic ssl library load.On Wednesday, 2 May 2018 at 00:04:49 UTC, IntegratedDimensions wrote:That seemed to work. Why would it not look in the current directory by default? Maybe something to add?On Tuesday, 1 May 2018 at 23:35:42 UTC, Arun Chandrasekaran wrote:Did you try to use full path to cacert.pem?[...]Ok, first try: Unhandled exception: object.Exception can't complete call to TLS_method at requests\ssl_adapter.d(248) which says it can't find the lib. I renamed ssleay32.dll to libssl32.dll and it then passed. I am getting http 404 error though ;/ I turned off cert though, which may be the reason, I have no idea. Seems to be working through.
May 02 2018