4

Newbie here. I am tasked to handle x509certificate in swift. It seems this x509 thing sounds scary. I try my best to describe what I want to achieve. Hope you can guide me.

Below is what I try to achieve:

1) I would like to know, what I need in Swift to handle the x509certificate p12 file and private Key
2) How to Sign with private key by RSA

In C#, below code is to get a private Key

public static RSACryptoServiceProvider UsePrivateKeyFromP12(string certFileName, string pwd)
{

var privateCert = new X509Certificate2(System.IO.File.ReadAllBytes(certificateFileName), password);

 return (RSACryptoServiceProvider)privateCert.PrivateKey;
}

How would I do in Swift? The private key will be on the client side.

Thanks

MilkBottle
  • 4,242
  • 13
  • 64
  • 146
  • you need the support of `open ssl`. try this https://stackoverflow.com/questions/43227984/ios-swift-x509-certificate-sign-string, and this :https://stackoverflow.com/questions/29489391/generate-base64-url-encoded-x-509-format-2048-bit-rsa-public-key-with-swift – caldera.sac Aug 31 '17 at 03:46
  • @Anuradh, the links have no mention of getting the PrivateKey and using RSA to handle the private key. – MilkBottle Aug 31 '17 at 05:41

0 Answers0