Skip to content

Commit 7af72b4

Browse files
author
Dave Nottage
committed
Update to Open SSL v3.x
1 parent f000c50 commit 7af72b4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Features/Firebase/DW.FCMSender.pas

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ implementation
201201
// RTL
202202
System.SysUtils, System.DateUtils, System.Net.HttpClient, System.Net.URLClient, System.NetEncoding, System.NetConsts,
203203
System.Hash, System.IOUtils, System.TypInfo, System.Generics.Collections,
204-
// Grijjy - from: https://github.com/grijjy/DelphiOpenSsl/blob/master/OpenSSL.Api_11.pas
205-
OpenSSL.Api_11;
204+
// DW
205+
DW.OpenSSL;
206206

207207
const
208208
CONTENTTYPE_APPLICATION_JSON = 'application/json'; // do not localize
@@ -282,17 +282,15 @@ function TGoogleJWT.SignSHA256WithRSA(const APrivateKey: TBytes; const AData: TB
282282
LPrivateKeyRef: PBIO;
283283
LPrivateKey: PEVP_PKEY;
284284
LContext: PEVP_MD_CTX;
285-
SHA256: PEVP_MD;
286285
LSize: NativeUInt;
287286
begin
288-
LPrivateKeyRef := BIO_new_mem_buf(@APrivateKey[0], Length(APrivateKey));
287+
LPrivateKeyRef := BIO_new_mem_buf(@APrivateKey[0], Length(APrivateKey));
289288
try
290289
LPrivateKey := PEM_read_bio_PrivateKey(LPrivateKeyRef, nil, nil, nil);
291290
try
292-
LContext := EVP_MD_CTX_create;
291+
LContext := EVP_MD_CTX_new;
293292
try
294-
SHA256 := EVP_sha256;
295-
if (EVP_DigestSignInit(LContext, nil, SHA256, nil, LPrivateKey) > 0) and
293+
if (EVP_DigestSignInit_ex(LContext, nil, 'SHA256', nil, nil, LPrivateKey, nil) > 0) and
296294
(EVP_DigestUpdate(LContext, @AData[0], Length(AData)) > 0) and
297295
(EVP_DigestSignFinal(LContext, nil, LSize) > 0) then
298296
begin
@@ -301,13 +299,13 @@ function TGoogleJWT.SignSHA256WithRSA(const APrivateKey: TBytes; const AData: TB
301299
SetLength(Result, 0);
302300
end;
303301
finally
304-
EVP_MD_CTX_destroy(LContext);
302+
EVP_MD_CTX_free(LContext);
305303
end;
306304
finally
307305
EVP_PKEY_free(LPrivateKey);
308306
end;
309307
finally
310-
BIO_free(LPrivateKeyRef);
308+
BIO_free(LPrivateKeyRef);
311309
end;
312310
end;
313311

@@ -557,6 +555,8 @@ function TFCMMessage.GetDataJSONValue: TJSONValue;
557555
// imageUrl is used in FCM handling code in Kastri
558556
if not FImageURL.IsEmpty then
559557
LData.AddPair('imageUrl', TJSONString.Create(FImageURL));
558+
if not FClickAction.IsEmpty then
559+
LData.AddPair('click_action', FClickAction);
560560
end;
561561
LHasData := LData.Count > 0;
562562
finally

0 commit comments

Comments
 (0)