Hi there.
I am try to use your code to call Card On File data inquiry endpoint and I got an error said" Expected input credential was not present". Details below:
The error is :
Could you please advise. Thanks
Hi @Dakuan ,
We have tested the C# sample code in the tutorial and it works fine.
Kindly note for 2-Way SSL, you don't need to provide the Root and Intermediate certificate.
I would suggest you to take the sample code provided in this tutorial as it is, replace with your credentials and add the below function with the VDP Sample Payload.
public string CardOnFileDataService()
{
string localTransactionDateTime = DateTime.Now.ToString("yyyy-MM-dd'T'HH:mm:ss");
string requestBody = "{\"requestHeader\":{\"requestMessageId\":\"6da6b8b024532a2e0eacb1af58581\",\"messageDateTime\":\"2019-02-3505:25:12.327\"},\"requestData\":{\"pANs\":[4072208010000000],\"group\":\"STANDARD\"}}";
string requestURL = "cofds-web/v1/datainfo";
return GetDecryptedPayload(DoMutualAuthCall(requestURL, "POST", "Card On File Data Service With MLE", getEncryptedPayload(requestBody), null));
}
And using the below main function to execute the API call.
static void Main(string[] args)
{
Program p = new Program();
string decryptedPayload = p.CardOnFileDataService();
Console.WriteLine("Decrypted Response\n" + decryptedPayload);
}
Please give it a try and let us know if you face any further issue.
Thank you
Hi @Dakuan ,
This looks more like an issue with your p12 file created.
Could you please double check the .p12 contains both the private and the public key. The below command should list the certificates in the .p12 file
openssl pkcs12 -info -in cert.p12
Kindly note that the the 2-Way SSL Certificate Subject contains the UID of your project and corresponding Key file with the same UID (in the file name) which you have downloaded, should be used to created the P12 file.
openssl pkcs12 -export -inkey key_<UID / PROJECT ID>.pem -in cert.pem -out cert.p12
The MLE private key is used for decrypting the response. Note that MLE Certificates and key contains the MLE Key ID so not to be confused with the 2Way SSL certificate.
//For MLE
public static string keyId = "<MLE_KEY_ID>";
public static string mleClientPrivateKey = "<PATH>/server_cert_<MLE_KEY_ID>.pem";
public static string mleServerPublicCertificate = "<PATH>/key_<MLE_KEY_ID>.pem";
I hope that helps.
Thank you
Hi @asaldanha
I know it is too late but want to leave the solution for the next error
Unable to cast object of type 'Org.BouncyCastle.X509.X509Certificate' to type 'Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair'.
The code below resolve this error
private static RSA ImportPrivateKey(string privateKeyFile) { var pr = new PemReader(File.OpenText(privateKeyFile)); var rsaPrivateKeyParameters = (RsaPrivateCrtKeyParameters)pr.ReadObject(); var rsaParams = DotNetUtilities.ToRSAParameters(rsaPrivateKeyParameters); var rsa = RSA.Create(); rsa.ImportParameters(rsaParams); return rsa; }