Hi all,

i'm trying to setup a backend system able to send push notification to mobile app (not developed in creatio) through FCM rest API.

The first hurdle is obtaining a valid token to authenticate to notification api exposed by firebase. In order to obtain this token i do have to call another rest api passing a jwt token generated by me and signed by a private key downloaded from fcm.

I've got a code (pasted below) that manages to generate this encrypted token and it's working in visual studio. But if i try to use it in a script task i got the exception 

'RSA' does not contain a definition for 'ImportPkcs8PrivateKey' and no accessible extension method 'ImportPkcs8PrivateKey' accepting a first argument of type 'RSA' could be found (are you missing a using directive or an assembly reference?)

As far as i know this exception is thrown if .net core being used is version 5 or below. But i'm on a demo instance with creation 8.2.0.4183 which should be already using net core 6 right?

Do you have any suggestion? (the flow is already configured to import System.Security.Cryptography)

 

 

--code--

   var now = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
var header = new Dictionary
       {
           { "alg", "RS256" },
           { "typ", "JWT" }
       };
string headerJson = JsonConvert.SerializeObject(header);
string encodedHeader = Convert.ToBase64String(Encoding.UTF8.GetBytes(headerJson)).TrimEnd('=').Replace('+', '-').Replace('/', '_');

var payload = new Dictionary
       {
           { "iss", CLIENT_EMAIL },
           { "scope", SCOPE },
           { "aud", TOKEN_URI },
           { "iat", now },
           { "exp", now + 3600 }
       };
string payloadJson = JsonConvert.SerializeObject(payload);
string encodedPayload = Convert.ToBase64String(Encoding.UTF8.GetBytes(payloadJson)).TrimEnd('=').Replace('+', '-').Replace('/', '_');
string unsignedJwt = $"{encodedHeader}.{encodedPayload}";
byte[] dataBytes = Encoding.UTF8.GetBytes(unsignedJwt);

// Decode PEM -> PKCS#8 bytes
string cleanKey = PRIVATE_KEY
   .Replace("-----BEGIN PRIVATE KEY-----", "")
   .Replace("-----END PRIVATE KEY-----", "")
   .Replace("\\n", "\n")  // ← decodifica reale da stringa JSON
   .Trim();


byte[] privateKeyBytes = Convert.FromBase64String(cleanKey);

// Firma con RSA-SHA256
byte[] signature;
using (var rsa = RSA.Create())
{
   rsa.ImportPkcs8PrivateKey(privateKeyBytes, out _);
   signature = rsa.SignData(dataBytes, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
}
string encodedSignature = Convert.ToBase64String(signature)
   .TrimEnd('=').Replace('+', '-').Replace('/', '_');

string jwt = $"{unsignedJwt}.{encodedSignature}";


return true;

Like 1

Like

1 comments
Best reply

Hi Roberto,

In the cloud-based demo version of Creatio (including your current instance), the Script Task in business processes runs under .NET Framework 4.7.2. This limitation is specific to the cloud version. If you run Creatio on-premises, it's possible to configure and run business logic under .NET Core instead.

As a result, the method ImportPkcs8PrivateKey() is not available in the cloud version. Other types like RSASignaturePadding, HashAlgorithmName, and RSA.Create() are also unavailable in this context.

Recommended Solution:
Move JWT generation to an external service
- Create a small Web API (in .NET 6 or above).
- Let it generate and return the signed JWT token.
- Call it from Creatio using HTTP request.

Hi Roberto,

In the cloud-based demo version of Creatio (including your current instance), the Script Task in business processes runs under .NET Framework 4.7.2. This limitation is specific to the cloud version. If you run Creatio on-premises, it's possible to configure and run business logic under .NET Core instead.

As a result, the method ImportPkcs8PrivateKey() is not available in the cloud version. Other types like RSASignaturePadding, HashAlgorithmName, and RSA.Create() are also unavailable in this context.

Recommended Solution:
Move JWT generation to an external service
- Create a small Web API (in .NET 6 or above).
- Let it generate and return the signed JWT token.
- Call it from Creatio using HTTP request.

Show all comments

Hello community,



We are using Creatio 7.16.3 Service enterprise on-premises (Infra on AWS cloud). We have a use case where certain fields on the Creatio GUI need to send and receive real time updates for a specific user across multiple browser client instances that s/he might be using.



We have zero-ed in on Firebase real time database to maintain state on the server side. We plan to establish Creatio client - Firebase interaction via the Firebase JS SDK to send and receive real time updates. Few clarifications below - 

 

1. Have there been known instances of Creatio successfully integrating with Firebase real time database in the past? If Yes, any available material/documentation around the same would help. 

2. Are there any gotchas or limitations we need to keep in mind from an implementation, security and performance perspectives specific to the Creatio product while integrating with Firebase real time database? Eg with Service workers. 

3. Firebase provides for including the JS SDK via a CDN link. I went through this article on how to include external JS libraries- https://community.creatio.com/questions/how-include-external-js-library-bpmonline. The answer provided seems incomplete/inconclusive. Would appreciate if someone could respond to my query. 

4. Is there a way to directly inject a CDN link globally on Creatio without having to physically include the contents of the file as suggested in the above link?



Thanks in advance!

Shrikanth

Like 0

Like

1 comments

Hello Shrikanth,

Please find my answers bellow:

 

1. We have checked the existing case history but unfortunately didn't find any request related to integration with Firebase service, sorry.

 

2. Unfortunately, we don't have any specific best practices for integrations. It is necessary to use generally accepted engineering practices and instructions but we will happy to assist with any difficulties you may have.

 

3. This question was already answered in the mentioned community post. Duplicating the answer here:

"Please call jQuery.getScript function in the console and review the sources tab as I recommended and use it as an example to add your own jQuery to the system"

 

4. As of now, there is no way to use CDN link in the Creatio application. If it will be available in future releases, you will be able to find this information in the Creatio release notes.

 

Please let us know if you have any other questions.

 

Best regards,

Roman

Show all comments