You are not logged in.
Hi @ab, I found a bug in the function mormot.crypt.openssl.OpenSslLoad.
function OpenSslLoad(const Cert: RawByteString): ICryptCert;
var
x: PX509;
der: RawByteString;
begin
result := nil;
der := PemToDer(Cert);
if not AsnDecChunk(der) then // basic input validation !!! HERE, the parameter must be `der` instead of `Cert`
exit;
x := LoadCertificate(der);
if x <> nil then
result := CryptCertOpenSsl[X509Algo(x)].FromHandle(x);
end;
Hi, using mormot.crypt.openssl.pas and mormot.lib.openssl11.pas with OPENSSLFULLAPI enabled and compiling too much errors Identifier redeclared: 'NID_info_access' and similars are raised. I commented on the redeclared.
UPDATE:
Missing record definition in mormot.lib.openssl11.full.inc
x509_val_st = record
notBefore: PASN1_TIME;
notAfter: PASN1_TIME;
end;
UPDATE 1:
In mormot.lib.openssl11.pas the OPENSSLSTATIC is not defined if OPENSSLFULLAPI is defined.
const
// some binaries may be retrieved from https://github.com/grijjy/DelphiOpenSsl
// or http://wiki.overbyte.eu/wiki/index.php/ICS_Download (more up-to-date)
// - on Windows, we found out that ICS OpenSSL 3 is slower than OpenSSL 1.1
{$ifdef OSWINDOWS}
{$ifdef CPU32}
LIB_CRYPTO1 = 'libcrypto-1_1.dll';
LIB_SSL1 = 'libssl-1_1.dll';
LIB_CRYPTO3 = 'libcrypto-3.dll';
LIB_SSL3 = 'libssl-3.dll';
_PU = '';
{$else}
LIB_CRYPTO1 = 'libcrypto-1_1-x64.dll';
LIB_SSL1 = 'libssl-1_1-x64.dll';
LIB_CRYPTO3 = 'libcrypto-3-x64.dll';
LIB_SSL3 = 'libssl-3-x64.dll';
_PU = '';
{$endif CPU32}
{$ifdef OPENSSLFULLAPI} //
{$define OPENSSLSTATIC} // with this is working
{$ENDIF OPENSSLFULLAPI} //
{$else}
...
UPDATE 2: in mormot.lib.openssl11.inc close bracket is in wrong position.
//function BIO_meth_get_write(p1: PBIO; p2: PUTF8Char; p3: Integer; biom: PBIO_METHOD): integer;
{ TODO : Cannot convert original type "int (*)(BIO *, const char *, int)" }; cdecl; //HERE
// external LIB_CRYPTO name _PU + 'BIO_meth_get_write';
//function BIO_meth_get_write_ex(p1: PBIO; p2: PUTF8Char; p3: PtrUIntp4: PPtrUInt; biom: PBIO_METHOD): integer;
{ TODO : Cannot convert original type "int (*)(BIO *, const char *, size_t, size_t *)" }; cdecl; //HERE
// external LIB_CRYPTO name _PU + 'BIO_meth_get_write_ex';
Commented with
//TODO: Cannot convert original ...
are with close bracket in wrong position.
There is much more compiler errors.
Thanks.
Thanks @chaa, first I'll try with http-01.
Thanks @ab !
Hi, after a long time I back to write a post, I want to know if is there any example/demo of ACME.
And, it's supported DNS challenge ?
Thanks in advance.
Esteban
I'm so sorry Pavlov. I'm from Argentina and our government is a shame, they are pro russian because they are corrupts like any populist government and need money from China and Russia and they only make a weak opposition to Putin's genocidal attack. Many people from my country are with your. I just wait that the world rest can help to Ukraine.
Check if you is doing commit retaining instead of hard commit.
Double escape "\", example:
{"ToAddress":"someaddress.gmail.com", "Attachment":"c:\\photos\\photo1.bmp"}
I agree with prefixing the framework with TSyn*, historically Delphi third party frameworks have used this. Even more, functions and procedure they should have a prefix, but thats is more complex for compatibility. It's just another opinion.
The new name is perfect for me. Have much make sense.
ok, @ab patched the @mpv pull request, the @ab speed is as warp 9 in Star Trek (and @mpv too).
I'll test that, thank you very much @mpv
Thanks @mpv, unfortunately our target development is Windows and I want migrate from Delphi 4 to FPC/Lazarus but with this limitation cannot will be possible.
Hi @ab, I tried compile LogView.lpi with Laz 2.0.8/FPC 3.2.0 and have error in SynMemoEx.pas:
const
RAEditorCompletionChars: set of AnsiChar =
[#8, '_', '0'..'9', 'A'..'Z', 'a'..'z'];
Separators: set of AnsiChar =
[#0, ' ', '-', #13, #10, '.', ',', '/', '\', ':', '+', '%', '*', '(', ')',
';', '=', '{', '}', '[', ']', '{', '}', '|', '!', '@', '"'];
the '{', '}' is duplicated.
UPDATE
SynMemoEx.pas(567,40) Error: Identifier not found "TCreateParams" in TCustomMemoEx in Laz 2.0.8 / FPC 3.2.0
With Delphi 10.3 no error is raised by the compiler (either duplicated entry and TCreateParams.
I thought that LogView was FPC/Windows compatible, my mistake.
Best regards.
I use TSynLog.Add.Log(all StackTrace, ...) and was very helpful.
Sure, I mean that the mORMot framework allow custom solutions, although I prefer to use mORMot features, RemObjects (my old version) also uses Indy and OpenSSL but the TWinHTTP is very superior.
I had similar needs but migrating from 3tier (with RemObjects) to 3tier (with mORMot). I implemented TSynRestDataset but using full mORMot features -not Indy, not OpenSSL, mORMot validators- (see https://synopse.info/forum/viewtopic.php?id=2712), we make small adaptations in out client applications (5, 10, 15 years) and all works fine. The mORMot framework greatness is infinite.
You are right, I zipped wrong version, I have updated in https://drive.google.com/open?id=0Bx7LP … jZFSE9hZ3c.
Thanks.
Yes, is what i am currently using with Delphi 7.
Ok, thank you very much.
Thank you @AOG !!! I'll investigate. One question: is needed asphyre for non graphical apps ?
all tests passed !!! Congratulations AOG !!!
Can you suggest me tutorials for Android development with Lazarus/FPC ? I know that there is someones in the net, but I don't know the more reliable.
Thanks.
Hi @ab, I have a problem rendering mustache template:
Template
{{^context.video.main.parts}}-v error -y -i {{context.video.main.sourcefilename}} {{context.video.main.tempfilename}}.avi{{/context.video.main.parts}}
{{#context.video.main.parts}}
{{#-first}}-v error -y -i {{context.video.main.sourcefilename}}{{/-first}}
{{^-last}} -ss {{startoffsetinsecs}} -t {{durationinsecs}} {{tempfilename}}.avi {{/-last}}
{{#-last}} -ss {{startoffsetinsecs}} {{tempfilename}}.avi{{/-last}}
{{/context.video.main.parts}}
Context (the context is a reduced version but same structure)
{
"context": {
"callrefid": "441299259001",
"audio": {
"main": {
"sourcefilename": "\\TECNOVOZ\\ACD\\Vox\\20191217\\11285401.139",
"parts": [],
"tempfilename": "C:\\Users\\EMartin\\AppData\\Local\\Temp\\A~44129925900100",
"destfilename": "\\TecnoVoz\\Streaming\\441299259001"
},
"holds": []
},
"video": {
"main": {
"sourcefilename": "\\TECNOVOZ\\ACD\\Video\\20191217\\01_0139_20191217_112854_0000000000.avi",
"parts": [{
"startoffsetinsecs": 0,
"durationinsecs": 275.333,
"tempfilename": "C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900101"
}, {
"startoffsetinsecs": 275.666,
"durationinsecs": 60.3339999999999,
"tempfilename": "C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900103"
}, {
"startoffsetinsecs": 1152,
"durationinsecs": 0,
"tempfilename": "C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900115"
}
],
"tempfilename": "C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900100",
"destfilename": "\\TecnoVoz\\Streaming\\441299259001"
},
"holds": [{
"sourcefilename": "\\TECNOVOZ\\ACD\\Video\\20191217\\01_0139_20191217_112854_0000000000_01.avi",
"tempfilename": "C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900102"
}, {
"sourcefilename": "\\TECNOVOZ\\ACD\\Video\\20191217\\01_0139_20191217_112854_0000000000_02.avi",
"tempfilename": "C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900104"
}, {
"sourcefilename": "\\TECNOVOZ\\ACD\\Video\\20191217\\01_0139_20191217_112854_0000000000_06.avi",
"tempfilename": "C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900112"
}
]
}
}
}
Result
[context] property not found in {"startoffsetinsecs":0,"durationinsecs":275.333,"tempfilename":"C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900101"}
When debugging I see try access to "startoffsetinsecs" starting from path "context.video.main.parts" and "context" not exists in array element {"startoffsetinsecs":0,"durationinsecs":275.333,"tempfilename":"C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900101"}.
Is this a bug or limited feature ?
Thanks.
I agree with @macfly, version 2 should be breaking change this way the migration will require the source code update.
on the other hand, ORM data response could be a class that could be replaced by other, for example for return in OData format ?
Thanks.
You mean that the text key always should be of 32 characteres ?
Hi @ab, I found the problem the compatibility (or not perhaps is by design):
in:
constructor TAESAbstract.Create(const aKey; aKeySize: cardinal);
begin
if (aKeySize<>128) and (aKeySize<>192) and (aKeySize<>256) then
raise ESynCrypto.CreateUTF8('%.Create(aKeySize=%): 128/192/256 required',[self,aKeySize]);
fKeySize := aKeySize;
fKeySizeBytes := fKeySize shr 3;
MoveFast(aKey,fKey,fKeySizeBytes); <<<--- (1)
end;
(1) if the key is, for example, "12345678" the byte array TAESKey should be:
[49, 50, 51, 52, 53, 54, 55, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
in other words, the rest of array should be completed with zeroes but is filled with other values that are valids. For workaround I added Key as property in TAESAbstract with read/write and after create I refilling with correct data and it works.
Can you tell me if this behavior is by design or bug ?
UPDATE:
I removed Key property from TAESAbstract and implemented TAESAbstrackHack for accessing fKey protected member.
I don't know how patch MoveFast for non-filling with invalid values the rest of byte array. I think that Create constructor should have extra parameter with length of key text.
Thanks.
Thanks @ab, my intention is move to FPC but out base code is huge and much UI with DevEx and other visual third party components, all these tasks take time and we are very small team. We have not Delphi 2007 license.
I agree at all, except excluding Delphi 7 because all our projects are developed with it and, unfortunately, with third party components. I initiated conversations with my boss for migrating UI to web and use FPC as tool for backend development, but that's something that takes time. Maybe support for Delphi 7 for a few years (you decide how long) will be fantastic.
Excellent idea of use the semantic versioning.
Units splitting should be for functionality in my opinion, for example SynJSON with all related support for JSON handling.
Maybe this thread shoud be post as "sticky".
Thanks @ab, I'll try that the provider modify the algorithm, but in case that's not posible, how use TAESCBC to make the encryption as in C# ?.
Thanks again.
The text <b>pepego</b> with key <b>Aesdns06</b> works ok in https://dotnetfiddle.net/tlO25C and was generated with a C# application.
Any idea why mORMot encryption not working ?
Thanks.
I need to generate a key using AES CBC 256 PKCS7 encryption for a .Net C# application that use this key for password when connection to database. The key have the form IV.KEY and is stored in a config file. I have the following code to generate the key in that way.
var
lKey: TBytes;
lIV: TAESBlock;
lText, lTextEncrypted, lIVText: RawByteString;
lAESCBC: TAESCBC;
begin
...
// edtKey.Text is KEY
// edtSource.Text is TEXT TO ENCRYPT
SetLength(lKey, Length(edtKey.Text));
SynCommons.HexToBin(Pointer(edtKey.Text), @lKey, Min(Length(edtKey.Text),SizeOf(lKey)));
RawByteStringToBytes(RawByteString(edtKey.Text), lKey);
lAESCBC := TAESCBC.Create(lKey, CRYPT_KEY_SIZES[2]{=256});
try
lText := StringToUTF8(edtSource.Text);
TAESPRNG.Main.FillRandom(lIV);
lAESCBC.IV := lIV;
lTextEncrypted := SynCommons.BinToBase64(lAESCBC.EncryptPKCS7(lText));
lIVText := SynCommons.BinToBase64(@lAESCBC.IV, SizeOf(lAESCBC.IV));
edtDest.Text := UTF8ToString(lTextEncrypted)+'.'+lIVText;
finally
lAESCBC.Free;
end;
...
end;
and the key generated with the above code
KEY=key
TEXT TO ENCRYPT=text to encrypt
oTfXA3+lm6aiOaGYjCsk+Q==.OX0qIq1iSEMhTdw/fl0ehg== (the dot is a separator)
raise an exception <b>Padding is invalid and cannot be removed.</b>
For testing I'm using dotfiddle.net in https://dotnetfiddle.net/tlO25C
What's wrong ?
Thanks.
sicShared works this way but then another mothods are also blocked.
Using lock/unlock inside the endpoint of interface service does not block other endpoints of the interface service.
We are using sicShared and when we need serialized access to somene services we use TSynLocker.Lock and TSynLocker.Unlock in a try .. finally.
You must encode url parameter (space = %20).
Very interesting !!! @ab is the new Martin Fowler ?
I used what I wrote in my last post.
With FPC Fixes3.2 and Lazarus trunk it works.
It works with FPC Fixes3.2 and Lazarus Fixes2.0, not works with FPC 3.3.1 and Lazarus 2.1.
"It works" mean that when added the SynCommons unit and run the project no error is raised.
Thanks @hnb.
PD: Is usefull try with FPC Fixes3.2 and Lazarus 2.1.0 ?
Ok, I'll use "fixes3.2" option from fpcupdeluxe.
A pity, whenever I try to initiate a migration to FPC some problem of this kind happens. My boss considers that these open source software are unstable, I try to convince him otherwise.
Thanks.
Thanks @hnb, that solve this error compilation, but now I have another:
"External: SIGSEGV" in this line:
..
if fElemType<>nil then begin
{$ifndef HASDIRECTTYPEINFO}
// FPC compatibility: if you have a GPF here at startup, your 3.1 trunk
// revision seems older than June 2016
// -> enable HASDIRECTTYPEINFO conditional below $ifdef VER3_1 in Synopse.inc
// or in your project's options
fElemType := PPointer(fElemType)^; // inlined DeRef() <-- THIS LINE
{$endif HASDIRECTTYPEINFO}
{$ifdef FPC}
if not (PTypeKind(fElemType)^ in tkManagedTypes) then
fElemType := nil; // as with Delphi
{$endif FPC}
end;
end;
..
I understand the warning comment but I downloaded, with FPCUpDeluxe, the trunk version (Lazarus 2.1.0 and FPC 3.3.1) ergo the revision is not that old.
What happend now ?
Thanks
Hi @ab, I'm starting try to use Lazarus/FPC. I have installed mORMot with FPCUpDeluxe, and I when added the unit SynCommons to default Lazarus project (after Lazarus is started) and when I compile I have the following error:
Compile Project, Target: D:\fpcupdeluxe\projects\project1.exe: Exit code 1, Errors: 1, Warnings: 5, Hints: 9
SynLZ.pas(652,18) Hint: Local variable "offset" does not seem to be initialized
SynLZ.pas(660,21) Warning: Local variable "cache" does not seem to be initialized
SynLZ.pas(723,7) Hint: Conversion between ordinals and pointers is not portable
SynLZ.pas(723,19) Hint: Conversion between ordinals and pointers is not portable
SynLZ.pas(724,10) Hint: Conversion between ordinals and pointers is not portable
SynLZ.pas(726,13) Hint: Conversion between ordinals and pointers is not portable
SynLZ.pas(728,9) Hint: Conversion between ordinals and pointers is not portable
SynLZ.pas(1196,51) Hint: Local variable "offset" does not seem to be initialized
SynLZ.pas(1286,69) Hint: Local variable "offset" does not seem to be initialized
SynLZ.pas(1325,18) Hint: Local variable "offset" does not seem to be initialized
SynLZ.pas(1333,21) Warning: Local variable "cache" does not seem to be initialized
SynCommons.pas(6661,23) Warning: Some fields coming after "" were not initialized
SynCommons.pas(13390,42) Warning: Some fields coming after "VType" were not initialized
SynCommons.pas(15038,56) Warning: Some fields coming after "VOptions" were not initialized
SynFPCTypInfo.pas(99,3) Fatal: Syntax error, "BEGIN" expected but "[" found
and the line in the unit is:
...
implementation
procedure FPCDynArrayClear(var a: Pointer; typeInfo: Pointer);
[external name 'FPC_DYNARRAY_CLEAR'];
procedure FPCFinalizeArray(p: Pointer; typeInfo: Pointer; elemCount: PtrUInt);
[external name 'FPC_FINALIZE_ARRAY'];
procedure FPCFinalize(Data: Pointer; TypeInfo: Pointer);
[external name 'FPC_FINALIZE'];
procedure FPCRecordCopy(const Source; var Dest; TypeInfo: pointer);
[external name 'FPC_COPY'];
procedure FPCRecordAddRef(var Data; TypeInfo : pointer);
[external name 'FPC_ADDREF'];
...
I installed trunk version of Lazarus/FPC with FPCUpDeluxe 1.6.2x, using {$mode delphi}.
What am I doing wrong ?
Thanks.
Try:
CurrentServiceContextServer.Error(400,'error message');
I don't remember the exact sintax.
Hi @ab, there is a small bug in SynDB.pas:
function TSQLDBConnectionPropertiesThreadSafe.CurrentThreadConnectionIndex: Integer;
var id: TThreadID;
tix: Int64;
conn: TSQLDBConnectionThreadSafe;
begin // caller made EnterCriticalSection(fConnectionCS)
if self<>nil then begin
...
result := 0;
-- while result<fConnectionPool.Count-1 do begin
++ while result<fConnectionPool.Count do begin
conn := TSQLDBConnectionThreadSafe(fConnectionPool.List[result]);
if conn.IsOutdated(tix) then // to guarantee reconnection
fConnectionPool.Delete(result) else begin
if conn.fThreadID=id then begin
fLatestConnectionRetrievedInPool := result;
exit;
end;
inc(result);
end;
end;
end;
result := -1;
end;
Just remove the -1 (minus one).
Thanks.
Thank you @ab.
Hi @ab, I created a pull request https://github.com/synopse/mORMot/pull/ … -282564854. I found a problem when creating connections and the cause is that the expired connections are not destroyed quicly. I need create many connections because I need drop tables and this way avoid the error "object is in use".
If you are agree can you apply the PR ?.
Thanks.
No es un framework fácil y la documentación es buena pero hay que leer un poco el código, así lo aprendí. Igual te recomiendo que hagas en inglés las consultas, usá el Google Translator o DeepL Translator.
This is my code uploading files using interface based services using TSQLRestClientURI:
function UpLoadFiles(const aSourceFiles, aDestFolder: RawUTF8; out aNotUploadedFiles: RawUTF8): Boolean;
var
I: Integer;
lMultiPart: TMultiPartDynArray;
lMultiPartFormData: RawUTF8;
lMultiPartContentType: RawUTF8;
lSourceFiles: TRawUTF8DynArray;
lResp: RawUTF8;
begin
Result := False;
CSVToRawUTF8DynArray(aSourceFiles, ',', '', lSourceFiles);
if Length(lSourceFiles)=0 then
Exit;
for I := 0 to Length(lSourceFiles)-1 do begin
MultiPartFormDataAddFile(lSourceFiles[I], lMultiPart);
if MultiPartFormDataEncode(lMultiPart, lMultiPartContentType, lMultiPartFormData) then
// fClient = instance of TSQLRestClientURI and logged
// change 'root' for your root
fClient.URI(FormatUTF8('%/UpFile?path=%', ['root', aDestFolder]),
'POST', @lResp, @lMultiPartContentType, @lMultiPartFormData)
else
AddToCSV(lSourceFiles[I],aNotUploadedFiles);
end;
Result := True;
end;
Use as reference for using TWinHTTP.
Saludos.
I use OnAuthenticationFailed event for automatic relogin
I trying migrate from Delphi 7 to FPC 3.3.1 and Lazarus 2.1.0 (I don't know anything of Lazarus/FPC), the OPM is very interesting and I have two questions:
1) Is posible that every time @ab update mORMot it is uploaded to http://packages.lazarus-ide.org/ automatically as with github ?
2) Is posible put in the OPM package version the content the synopsecommit.inc ? This way the last update is knowed.
Thanks.
Thanks @sevo.
I can assure that enumDescription is not filled in mORMotWrapper.pas and it's very likely the other types aren't either.