title: golang, can i create X509KeyPair using rsa key?
body: <p>I am trying to create gRPC connection with mutual tls following the instruction on this blog <a href="http://bbengfort.github.io/programmer/2017/03/03/secure-grpc.html" rel="nofollow noreferrer">Secure gRPC with TLS/SSL</a>, but i don't want to create the certificate and save it to a file on the disk, I want the service itself to create its keys, then the certificate authority key will be taken somewhere else (I am planning using the google pki as the ca).</p>
  
  <p>What i did so far I can create the private/public key pair using rsa, then encode the public key to pem key following some code here <a href="https://www.socketloop.com/tutorials/golang-generate-dsa-private-public-key-and-pem-files-example" rel="nofollow noreferrer">Golang : Generate DSA private, public key and PEM files example</a> now i am stock on how to create the certificate using the <a href="https://golang.org/pkg/crypto/tls/#LoadX509KeyPair" rel="nofollow noreferrer">LoadX509KeyPair</a>. I don't know where to get the value for the second parameter, it needs keyPemBlock in bytes, but the RSA private key is not on bytes.</p>
  
  <p>I would like to ask, is there a much more better way to create a certificate using the RSA, if it is possible?</p>
  
  <p>And also if we can create a certificate using RSA; using the incomplete solution of mine above, where i can get the value for the second parameter of the <code>tls.LoadX509KeyPair</code>?</p>
  
  <p>Thank you</p>