title: How to create .cer from apple api json
body: <p>I need to make automatic for all apple operations: </p>
  
  <ul>
  <li>create csr (i did in terminal with openssl)</li>
  <li>Create certificate in developer.apple (i used apple api <a href="https://developer.apple.com/documentation/appstoreconnectapi/create_a_certificate" rel="nofollow noreferrer">https://developer.apple.com/documentation/appstoreconnectapi/create_a_certificate</a>)</li>
  <li>Need to get certificate detail and i did but i could not download .cer file from returned response. In manually case it can be install from developer.apple.com, so i need to do it dynamic from my software.</li>
  </ul>
  
  <p>Response example: ([GET] <a href="https://api.appstoreconnect.apple.com/v1/certificates/" rel="nofollow noreferrer">https://api.appstoreconnect.apple.com/v1/certificates/</a>{id}
  )</p>
  
  <pre><code>  "data": {
      "type": "certificates",
      "id": "cert id xxxx",
      "attributes": {
        "serialNumber": "xxxxx",
        "certificateContent": "cer content...",
        "displayName": "xxx",
        "name": "iOS Distribution: xxx",
        "csrContent": null,
        "platform": "IOS",
        "expirationDate": "2020-09-03T20:03:52.000+0000",
        "certificateType": "IOS_DISTRIBUTION"
      },
      "links": {
        "self": "https://api.appstoreconnect.apple.com/v1/certificates/xxx"
      }
    },
    "links": {
      "self": "https://api.appstoreconnect.apple.com/v1/certificates/xxx"
    }
  }
  </code></pre>
  
  <p>Apple says you can download with this api and i researched how to create .cer from this data therefore i could not.</p>
  
  <p><strong>Note</strong>: If decode "certificateContent" i can see my company information.</p>
  
  <p><strong>Summarize</strong>: I need to create cer from this response and add to keychain with 
  this command: <code>security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ios_distribution.cer</code></p>