title: Authenticating Kubernetes API(NodeJS) client using certificate not successful
body: <p>I have deployed a Kubernetes cluster in google cloud and trying to access it using the <a href="https://github.com/Goyoo/node-k8s-client" rel="nofollow noreferrer"><strong>Kubernetes NodeJS API</strong></a>, a kubernetes client.</p>
  
  <p>To do so, we need to authenticate with cluster. I tried using just the <strong><a href="https://github.com/Goyoo/node-k8s-client#authentication" rel="nofollow noreferrer">Username and Password</a></strong> method. I get the following error:</p>
  
  <pre><code>{ [Error: unable to verify the first certificate] code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' }
  </code></pre>
  
  <p>Then I tried the authentication using the <a href="https://github.com/Goyoo/node-k8s-client#authentication" rel="nofollow noreferrer"><strong>CAcert, ClientCert and ClientKey</strong></a>. I basically hardcoded the keys instead of importing it from the files. I am calling this API from a Lambda function, where I cant store the certs in files. Doing so, I get the below error:</p>
  
  <pre><code>[Error: error:0906D06C:PEM routines:PEM_read_bio:no start line]
  </code></pre>
  
  <p>My intuition is authentication is possible only with keys. But I think I am doing something wrong with the certs. Do I need to create some other certificates out of this or is the method of using the certs is wrong ?</p>
  
  <p><strong>Answer:</strong></p>
  
  <p>See the <strong>Robert Bailey's</strong> comment. I was missing the <strong>Base64</strong> thing. Adding that, I could successfully authenticate to the kubernetes cluster and display and deploy new pods, etc.,</p>