You are not logged in.
Pages: 1
Hi Guys,
Are any way to access internal record curl.easy_setopt... ?
I need this to set additional configuration to curl.
Perhaps by putting types and variables (TCurlOption, TCurlResult, curl, ...) in global scope.
Last edited by macfly (2019-03-11 14:42:20)
Offline
Online
I share the propose with @mpv.
:-)
Offline
Excellent news.
The idea of creating a unit separates is great.
The implementation of Curl in Mormot is the best that exists for delphi / Lazarus. It deserves a specific unit.
Offline
I create a SynCurl unit and move there all curl low level API - see https://github.com/synopse/mORMot/pull/231 (@ab - please, merge if it compiles under Delphi )
Tested on both Windows & Linux with FPC compiler.
We switch to libcurl for accessing LDAP catalogues (instead of synApse 4) - in some catalogue configurations synapse does not work. Now I want to use libclurl for IMAP/POP/SMPT also
Last edited by mpv (2019-08-28 16:32:08)
Online
@ab, please, can you merge a SynCurl into master? Or give me feedback if something wrong there.
This is just a copy-paste from SynCrtSock so I do not expect any regression.
It's critical for me to have a low level access to libcurl
Last edited by mpv (2019-09-02 09:37:34)
Online
I have merged it, with some fixes for Delphi compatibility and mORMot-standard documentation.
Online
/// low-level libcurl library file name, depending on the running OS
LIBCURL_DLL = {$ifdef Darwin} 'libcurl.dylib' {$else}
{$ifdef Linux} 'libcurl.so' {$else} 'libcurl-x64.dll' {$endif}{$endif};
What about Win32 platform? Is it no longer supported?
Offline
@Zed
Nice catch.
This was a regression induced by the merge request.
Please check https://synopse.info/fossil/info/0a257a244c
Online
Thanks @mpv and @ab.
The ability to use CURL separately is a big feature.
Offline
@ab - thanks!
IMHO one of HUGE advantage of libcurl is diagnostic - calling `curl -v URL` from command line shows all network packages with very human friendly errors. Doing so we catch very unclear errors with certificates and LDAP catalogue configurations
A small code snippet for client authorization using LDAP (verified with very exotic ActiveDirectory configuration where SynApse don't work, also with OpenLDAP). Consider client pass password in base64
LDAP connection string stored in config, example: aLDAPCfg.URL = 'ldaps://mydomain.com:636/DC=mydomain,DC=com?cn?sub?(sAMAccountName=%)'
curlHandle := curl.easy_init;
curlLdapURL := FormatUTF8(aLDAPCfg.URL, [aUserWODomain]);
curl.easy_setopt(curlHandle,coURL,pointer(curlLdapURL));
pwd := UTF8ToString(Base64ToBin(aPassWord));
if (pwd = '') then begin
Result := false;
errReason := FormatUTF8('LDAP anonymous logon attempt for %', [aUserName]);
end else begin
curlUserPwd := FormatUTF8('%:%', [aUserName, pwd]);
curl.easy_setopt(curlHandle, coUserPwd, pointer(curlUserPwd));
if (aLDAPCfg.ignoreSSLCertificateErrors) then begin
curl.easy_setopt(curlHandle, coSSLVerifyPeer, 0);
curl.easy_setopt(curlHandle, coSSLVerifyHost, 0);
end else if (aLDAPCfg.CAPath <> '') then
curl.easy_setopt(curlHandle, coCAPath, pointer(aLDAPCfg.CAPath));
curl.easy_setopt(curlHandle, coWriteFunction, @CurlWriteRawByteString);
curl.easy_setopt(curlHandle, coFile, @curlRespBody);
res := curl.easy_perform(curlHandle);
Result := (res = crOK);
if not Result then begin
Result := false;
errReason := FormatUTF8('LDAP libCurl error #%: %', [ord(res), curl.easy_strerror(res)]);
end;
end;
curl.easy_cleanup(curlHandle);
Last edited by mpv (2019-09-04 09:27:27)
Online
Pages: 1