report.CRITICAL: Empty or no Private Key provided [] [] - magento2

After the upgrade from M2.3.3 to M2.4.2 checkout page is not working.
In system.log file I am getting an error:
[2021-04-27 10:35:21] report.CRITICAL: Empty or no Private Key provided [] []
Anyone having idea on this?

There's little to no details to go on on based on your error, alas with some googling I've ended up at this exception:
https://github.com/open-pay/openpay-php/blob/master/data/OpenpayApiConnector.php#L45
$myApiKey = Openpay::getApiKey();
if (!$myApiKey) {
throw new OpenpayApiAuthError("Empty or no Private Key provided");
} else if (!preg_match('/^sk_[a-z0-9]{32}$/i', $myApiKey)) {
throw new OpenpayApiAuthError("Invalid Private Key '".$myApiKey."'");
}
Which I suppose indicates you're using a module to interact with OpenPay's API ( maybe this one? ) in which case you may wanna double-check your private key are all sorted out in your back-end config:

Related

PKCS#11Interop.X509Store unable to find Private Key

Pkcs11X509Certificate is unable to find the private key in some tokens.
Pkcs11X509Certificate.GetRSAPrivateKey() yields null. Then, when I run SignedXml.ComputeSignature(), I get the following error:
System.Security.Cryptography.CryptographicException: 'Signing key is not loaded.'
Adding the code below (proof of concept) to the Pkcs11X509Certificate.FindKey works.
Basically I removed CKA.CKA_LABEL from the search template attributes and it finds the certificate Private Key.
// Contrary to what PKCS#11 specification suggests, subject of the private key is not readable even after login.
// So if we cannot find private key with subject, we will search for private keys without subject.
if (keyHandle == null)
{
searchTemplate = new List<IObjectAttribute>()
{
session.Factories.ObjectAttributeFactory.Create(CKA.CKA_CLASS, keyClass),
session.Factories.ObjectAttributeFactory.Create(CKA.CKA_TOKEN, true),
session.Factories.ObjectAttributeFactory.Create(CKA.CKA_ID, ckaId),
//session.Factories.ObjectAttributeFactory.Create(CKA.CKA_LABEL, ckaLabel),
};
foreach (IObjectHandle foundObjectHandle in session.FindAllObjects(searchTemplate))
{
keyHandle = foundObjectHandle;
break;
}
}

Azure Mobile Offline Sync: Cannot delete an operation from __operations

I'm having a huge issue that I've been trying for days to get through. I have a scenario in which I'm trying to handle an Insert Conflict in my Xamarin project. The issue is that the record in the Cloud DB doesn't exist because there was an issue with a foreign key constraint so I'm in a scenario in which the sync conflict handler needs to delete the local record along with the record in the __operations table in SQLite. I've tried everything. Purge with the override set to 'true' so that it should delete the local record and all operations associated. Doesn't work. I've been just trying to force delete it by accessing the SQL store manually:
var id = localItem[MobileServiceSystemColumns.Id];
var operationQuery = await store.ExecuteQueryAsync("__operations", $"SELECT * FROM __operations WHERE itemId = '{id}'", null).ConfigureAwait(false);
var syncOperation = operationQuery.FirstOrDefault();
var tableName = operation.Table.TableName;
await store.DeleteAsync(tableName, new List<string>(){ id.ToString() });
if (syncOperation != null)
{
await store.DeleteAsync("__operations", new List<string>() { syncOperation["id"].ToString() }).ConfigureAwait(false);
}
I am able to query the __operations table and I can see the ID of the item I want to delete. The DeleteAsync method runs without exception but no status is returned so I have no idea if this worked or not. When I try to sync again the operation stubbornly exists. This seems ridiculous. How do I just delete an operation without having to sync with the web service? I'm about to dig down further and try to force it even harder by using the SQLiteRaw library but I'm really really hoping I'm missing something obvious? Can anyone help? THANKS!
You need to have a subclass of the Microsoft.WindowsAzure.MobileServices.Sync.MobileServiceSyncHandler class, which overrides OnPushCompleteAsync() in order to handle conflicts and other errors. Let's call the class SyncHandler:
public class SyncHandler : MobileServiceSyncHandler
{
public override async Task OnPushCompleteAsync(MobileServicePushCompletionResult result)
{
foreach (var error in result.Errors)
{
await ResolveConflictAsync(error);
}
await base.OnPushCompleteAsync(result);
}
private static async Task ResolveConflictAsync(MobileServiceTableOperationError error)
{
Debug.WriteLine($"Resolve Conflict for Item: {error.Item} vs serverItem: {error.Result}");
var serverItem = error.Result;
var localItem = error.Item;
if (Equals(serverItem, localItem))
{
// Items are the same, so ignore the conflict
await error.CancelAndUpdateItemAsync(serverItem);
}
else // check server item and local item or the error for criteria you care about
{
// Cancels the table operation and discards the local instance of the item.
await error.CancelAndDiscardItemAsync();
}
}
}
Include an instance of this SyncHandler() when you initialize your MobileServiceClient:
await MobileServiceClient.SyncContext.InitializeAsync(store, new SyncHandler()).ConfigureAwait(false);
Read up on the MobileServiceTableOperationError to see other conflicts you can handle as well as its methods to allow resolving them.

unable to locate a 'Type' by the name: ''. Be sure to execute a query or call fetchMetadata first

I've referenced all existing threads related to the same issue and didn't find any help.
Basically, I'm creating an EntityError collection which contains some validation errors. I add EntityErrors to this collection as follows:
if (!String.IsNullOrEmpty(user.UserCode))
{
if (_usersRepo.HasUserCode(user.Id, user.UserCode, clientId))
{
entityErrors.Add(new EntityError() { EntityTypeName = entityTypeName, ErrorMessage = "UserCode already exist", ErrorName = errorName, PropertyName = "UserCode", KeyValues = new object[] { user.UserCode } });
}
}
Then I throw the collection as follows:
throw new EntityErrorsException(validationErrors);
I get the above mentioned error, only after introducing the KeyValues in to the EntityError object, without that the errors are thrown to the application and displayed correctly.
As some of the previous posts have suggested, I tried adding Manager.FetchMetaData before calling this validation, but still it didn't work.
Following are the http responses when I get the error vs when it works as expected. You can see that when the error is thrown, KeyValues has a value, and when it works KeyValues is null.
When it works:
{"$id":"1","$type":"Breeze.ContextProvider.SaveError, Breeze.ContextProvider","Message":"Exception of type 'Breeze.ContextProvider.EntityErrorsException' was thrown.","EntityErrors":[{"$id":"2","$type":"Breeze.ContextProvider.EntityError, Breeze.ContextProvider","ErrorName":"Attribute Validation Error","EntityTypeName":"Users","KeyValues":null,"PropertyName":"UserCode","ErrorMessage":"UserCode already exist"}]}
enter code here
When it errors:
{"$id":"1","$type":"Breeze.ContextProvider.SaveError, Breeze.ContextProvider","Message":"Exception of type 'Breeze.ContextProvider.EntityErrorsException' was thrown.","EntityErrors":[{"$id":"2","$type":"Breeze.ContextProvider.EntityError, Breeze.ContextProvider","ErrorName":"Attribute Validation Error","EntityTypeName":"Users","KeyValues":["782"],"PropertyName":"UserCode","ErrorMessage":"UserCode already exist"}]}

Google sites API, IllegalArgumentException("Trying to set foreign cookie") after RedirectRequiredException

I am using the gdata-media-1.0-1.47.1.jar functionality to fetch media data using the com.google.gdata.client.media.MediaService.getMedia(IMediaContent mediaContent) method. For some requests I get a RedirectRequiredException. When I redo the getMedia request, using the url i get from RedirectRequiredException.getRedirectLocation(), I get an IllegalArgumentException("Trying to set foreign cookie") exception.
From what I can see, the reason for this is that the domain in the response header for the cookie doesn't match the domain of the redirect location. In com.google.gdata.client.http.GoogleGDataRequest.matchDomain() the first argument is ".docs.google.com" and the second is "docs.google.com" which makes the domain matching fail.
Is this a correct behaviour? Why is this happening? Is there something I can do about this? Am I doing anything wrong here? Is is possible to avoid this problem?
SitesService sitesService = new SitesService("SomeAppName");
try {
MediaContent mc = new MediaContent();
mc.setUri(aURI);
return sitesService.getMedia(mc);
} catch (RedirectRequiredException e) {
MediaContent mc = new MediaContent();
mc.setUri(e.getRedirectLocation());
return sitesService.getMedia(mc);
}

The given key was not present in the dictionary

I am developing a plugin in crm 5.0 to retrieve date "ct_valuedate" from an entity called "ct_marketvalue" and formatting and saving in a field called "ct_dateserial"
I get an error while I debug "The given key was not present in the dictionary"
public class MarketValueDateFormatting : PluginBase
{
protected override void ExecutePlugin()
{
try
{
switch (_crmMessage)
{
case CrmPluginMessageEnum.Create:
if (_context.InputParameters.Contains("ct_marketvalue"))
{
//Obtain the logical name of the entity
string moniker1 = ((EntityReference)_context.InputParameters["EntityMoniker"]).LogicalName;
//Verify that the target entity represents an Account.
//If not, this plug-in was not registered correctly.
if (moniker1.Equals("ct_marketvalue"))
{
Entity marketvalueimage = (Entity)_context.PostEntityImages["ct_marketvalue"];
Guid marketvalueid = marketvalueimage.Id;
if (marketvalueimage.Contains("ct_valuedate"))
{
DateTime dateserial = (DateTime)marketvalueimage.Attributes["ct_valuedate"];
String dateserialstring = dateserial.ToString("YYYYMMdd");
Ct_marketvalue marketvalue = new Ct_marketvalue();
marketvalue.Ct_dateserial = dateserialstring;
marketvalue.Id = marketvalueid;
_serviceContext.UpdateObject(marketvalue);
}
}
}
break;
}
catch (Exception ex)
{
throw ex;
}
}
}
}
Few notes about your code.
You should check in your code that _context.PostEntityImages contains "ct_marketvalue". It's possible either to forgot register or to do a mistake in image name.
Might be better use .ToEntity rather than access attributes using .Attributes["ct_valuedate"].
I'm not sure what is purpose of the plugin you wrote, but it looks it is post stage plugin and it updates the same entity instance, that was in InputParameters. Might be better to make this plugin pre stage and update value directly in InputParameters. Because, if not "The given key was not present in the dictionary" exception, it will cause infinite loop. You will need check context.Depth.