<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to Create .pem File for Apple Pay in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/How-to-Create-pem-File-for-Apple-Pay/m-p/84400#M53190</link>
    <description>&lt;P&gt;I am creating payment functionality with Apple Pay. I have used the CSR file to create a merchant_id.CER file from Apple developer portal.&lt;/P&gt;&lt;P&gt;using curl&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;curl --data '{"merchantIdentifier":"merchant.xxxxx", "domainName":"&lt;A href="http://www.xxxxxx.com" target="_blank"&gt;www.xxxxxx.com&lt;/A&gt;", "displayName":"xxxxx xxx xxxxx", "initiative": "web", "initiativeContext": "&lt;A href="http://www.xxxxxx.com" target="_blank"&gt;www.xxxxxx.com&lt;/A&gt;"}' -H "Content-Type: application/json" -X POST --cert ./certificates/merchant_id.cer &lt;A href="https://apple-pay-gateway.apple.com/paymentservices/paymentSession" target="_blank"&gt;https://apple-pay-gateway.apple.com/paymentservices/paymentSession&lt;/A&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;It's returning an error&lt;/DIV&gt;&lt;DIV&gt;curl: (58) could not load PEM client certificate, LibreSSL error error:09FFF06C:PEM routines:CRYPTO_internal:no start line, (no key found, wrong pass phrase, or wrong file format?)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I looked at Authorize.net sample project for Apple Pay JS and i noticed a pem file.&lt;/DIV&gt;&lt;DIV&gt;&lt;A href="https://github.com/AuthorizeNet/accept-sample-app/tree/master/certs" target="_blank"&gt;https://github.com/AuthorizeNet/accept-sample-app/tree/master/certs&lt;/A&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;How Do We Create a pem file using cer file?&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Based on Apple Documentation - It looks like we need a private key (root of the csr file) to create the pem file&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 05 Oct 2022 14:42:19 GMT</pubDate>
    <dc:creator>andrewoodleyjr</dc:creator>
    <dc:date>2022-10-05T14:42:19Z</dc:date>
    <item>
      <title>How to Create .pem File for Apple Pay</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/How-to-Create-pem-File-for-Apple-Pay/m-p/84400#M53190</link>
      <description>&lt;P&gt;I am creating payment functionality with Apple Pay. I have used the CSR file to create a merchant_id.CER file from Apple developer portal.&lt;/P&gt;&lt;P&gt;using curl&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;curl --data '{"merchantIdentifier":"merchant.xxxxx", "domainName":"&lt;A href="http://www.xxxxxx.com" target="_blank"&gt;www.xxxxxx.com&lt;/A&gt;", "displayName":"xxxxx xxx xxxxx", "initiative": "web", "initiativeContext": "&lt;A href="http://www.xxxxxx.com" target="_blank"&gt;www.xxxxxx.com&lt;/A&gt;"}' -H "Content-Type: application/json" -X POST --cert ./certificates/merchant_id.cer &lt;A href="https://apple-pay-gateway.apple.com/paymentservices/paymentSession" target="_blank"&gt;https://apple-pay-gateway.apple.com/paymentservices/paymentSession&lt;/A&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;It's returning an error&lt;/DIV&gt;&lt;DIV&gt;curl: (58) could not load PEM client certificate, LibreSSL error error:09FFF06C:PEM routines:CRYPTO_internal:no start line, (no key found, wrong pass phrase, or wrong file format?)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I looked at Authorize.net sample project for Apple Pay JS and i noticed a pem file.&lt;/DIV&gt;&lt;DIV&gt;&lt;A href="https://github.com/AuthorizeNet/accept-sample-app/tree/master/certs" target="_blank"&gt;https://github.com/AuthorizeNet/accept-sample-app/tree/master/certs&lt;/A&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;How Do We Create a pem file using cer file?&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Based on Apple Documentation - It looks like we need a private key (root of the csr file) to create the pem file&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 05 Oct 2022 14:42:19 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/How-to-Create-pem-File-for-Apple-Pay/m-p/84400#M53190</guid>
      <dc:creator>andrewoodleyjr</dc:creator>
      <dc:date>2022-10-05T14:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create .pem File for Apple Pay</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/How-to-Create-pem-File-for-Apple-Pay/m-p/85188#M53572</link>
      <description>&lt;P&gt;&lt;SPAN&gt;To create a Payment Processing certificate&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;In Member Center, select Certificates, Identifiers &amp;amp; Profiles.&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;Under Identifiers, select Merchant IDs. Select the merchant ID from the list, and click Edit. In the Payment Processing Certificates section. click Create Certificate.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 16:22:58 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/How-to-Create-pem-File-for-Apple-Pay/m-p/85188#M53572</guid>
      <dc:creator>websopedia387</dc:creator>
      <dc:date>2022-12-08T16:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create .pem File for Apple Pay</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/How-to-Create-pem-File-for-Apple-Pay/m-p/86715#M54577</link>
      <description>&lt;P&gt;I also want to create the .pem file. I have the merchant_id.cer and&amp;nbsp;apple_pay.cer but don't know how to create it.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 09:39:03 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/How-to-Create-pem-File-for-Apple-Pay/m-p/86715#M54577</guid>
      <dc:creator>rakeshfrom1985</dc:creator>
      <dc:date>2023-06-08T09:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create .pem File for Apple Pay</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/How-to-Create-pem-File-for-Apple-Pay/m-p/86731#M54587</link>
      <description>&lt;P&gt;I have create the files. I followed the following link&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/norfolkmustard/ApplePayJS/blob/master/README.md" target="_blank"&gt;https://github.com/norfolkmustard/ApplePayJS/blob/master/README.md&lt;/A&gt;&lt;/P&gt;&lt;P&gt;if you do not want to create the separate files from p12 file then you can use the below command to create a single file.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;$ openssl pkcs12 -in Certificates.p12 -out apple-pay-cert.pem -nodes -clcerts&lt;/LI-CODE&gt;&lt;P&gt;you can test the created fine using the curl command.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;$ curl -gv --data '{"merchantIdentifier":"merchant.com.testbed.applepay", "initiativeContext":"mydomain.com", "initiative":"web", "displayName":"Apple Pay Testbed"}' --cert /path/to/pem/apple-pay-cert.pem https://apple-pay-gateway.apple.com/paymentservices/paymentSession&lt;/LI-CODE&gt;&lt;P&gt;modify the different values according to your setup.&lt;/P&gt;&lt;P&gt;Using curl I am getting the proper response but when I host my asp.net core code on server the it is not working.&lt;/P&gt;&lt;P&gt;Below is the code sample.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var certificateBytes = await System.IO.File.ReadAllBytesAsync(certificatePath);
var certificate = new X509Certificate2(certificateBytes);
// Prepare the request data
var requestData1 = new
{
merchantIdentifier = "merchant.com.staggerallfilters",
initiativeContext = "stagger.allfilters.com",
initiative = "web",
displayName = "Stagger.AllFilters.Com"
};
var jsonRequestData = JsonConvert.SerializeObject(requestData1);
var content = new StringContent(jsonRequestData, Encoding.UTF8, "application/json");

// Create the HTTP client
var handler = new HttpClientHandler()
{
ClientCertificateOptions = ClientCertificateOption.Manual,
SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13,
AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip,
};
handler.ClientCertificates.Add(certificate);

var client = new HttpClient(handler);

// Send the request
var response = await client.PostAsync(requestData.validationUrl, content);

// Read the response
var responseContent = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
return Ok(responseContent);
}
else
{
return BadRequest(responseContent);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 11:26:43 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/How-to-Create-pem-File-for-Apple-Pay/m-p/86731#M54587</guid>
      <dc:creator>rakeshfrom1985</dc:creator>
      <dc:date>2023-06-09T11:26:43Z</dc:date>
    </item>
  </channel>
</rss>

