Nativescript Sidekick iOs on windows

nativescriptcore
ios

#1

I am starting using sidekick for building my mobile apps. I am on windows 10 and have done a build for android. All good. But iOs seem to be bit tricky. I had generated certificate /provisions and the build button for iOs is enabled. But when I click build it is throwing an error. Please someone help out in figuring out this. Many thanks

Exception details below

[17-11-14 13:55:54.117] (Error) Command failed: C:\Users\userAppData\Local\NativeScriptSidekick\app-1.0.0-v20171163\
resources\app.asar.unpacked\modules\certificate-store\binaries\win32\CertificateStoreUtilities.exe
 export -o C:\Users\user\AppData\Local\Temp\c59114ef-5ca6-4e75-a221-aaa328ba706e.p12 
 -p 65eadc93-53d7-4216-97bb-a113c1011b58 -s 3971505E83501B6F

NativeScriptSidekick Unhandled Exception: System.Security.Cryptography.CryptographicException: Key not valid for use in specified state.

   at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
   at System.Security.Cryptography.X509Certificates.X509Utils._ExportCertificatesToBlob(SafeCertStoreHandle 
   safeCertStoreHandle, X509ContentType contentType, IntPtr password)
   at System.Security.Cryptography.X509Certificates.X509Certificate.ExportHelper(X509ContentType contentType, Object password)
   at System.Security.Cryptography.X509Certificates.X509Certificate.Export(X509ContentType contentType, String password)
   at CertificateStoreUtilities.CertificateStoreUtilities.<>c__DisplayClass6_0.<ExportCertificate>b__0(X509Store store)
   at CertificateStoreUtilities.X509StoreHelper.Execute[T](StoreOptions options, Func`2 action)
   at CertificateStoreUtilities.CertificateStoreUtilities.ExportCertificate(ExportOptions options)
   at CertificateStoreUtilities.CertificateStoreUtilities.<>c.<ParseAndExecute>b__3_0(String verb, Object options)
   at CommandLine.Parser.ParseArguments(String[] args, Object options, Action`2 onVerbCommand)
   at CertificateStoreUtilities.CertificateStoreUtilities.ParseAndExecute(String[] args)
   at CertificateStoreUtilities.CertificateStoreUtilities.Main(String[] args)
, Error: Command failed: C:\Users\user\AppData\Local\NativeScriptSidekick\app-1.0.0-v20171163\resources\app.asar.unpacked\modules\certificate-store\binaries\win32\CertificateStoreUtilities.exe export -o C:\Users\somitha\AppData\Local\Temp\c59114ef-5ca6-4e75-a221-aaa328ba706e.p12 -p 65eadc93-53d7-4216-97bb-a113c1011b58 -s 3971505E83501B6F

Unhandled Exception: System.Security.Cryptography.CryptographicException: Key not valid for use in specified state.

   at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
   at System.Security.Cryptography.X509Certificates.X509Utils._ExportCertificatesToBlob(SafeCertStoreHandle safeCertStoreHandle, X509ContentType contentType, IntPtr password)
   at System.Security.Cryptography.X509Certificates.X509Certificate.ExportHelper(X509ContentType contentType, Object password)
   at System.Security.Cryptography.X509Certificates.X509Certificate.Export(X509ContentType contentType, String password)
   at CertificateStoreUtilities.CertificateStoreUtilities.<>c__DisplayClass6_0.<ExportCertificate>b__0(X509Store store)
   at CertificateStoreUtilities.X509StoreHelper.Execute[T](StoreOptions options, Func`2 action)
   at CertificateStoreUtilities.CertificateStoreUtilities.ExportCertificate(ExportOptions options)
   at CertificateStoreUtilities.CertificateStoreUtilities.<>c.<ParseAndExecute>b__3_0(String verb, Object options)
   at CommandLine.Parser.ParseArguments(String[] args, Object options, Action`2 onVerbCommand)
   at CertificateStoreUtilities.CertificateStoreUtilities.ParseAndExecute(String[] args)
   at CertificateStoreUtilities.CertificateStoreUtilities.Main(String[] args)

    at ChildProcess.exithandler (child_process.js:217:12)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:194:7)
    at maybeClose (internal/child_process.js:899:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

#2

Hi There, the issue with this was I was using a .pfx file but I had to use .p12 and that solved it.


#3

I didn’t understand this solution initially. I received the same error but never had a PFX file.

The basic workflow is this:

  • Generate CSR in Sidekick
  • Upload CSR to Apple Dev Portal
  • Download CER from Apple
  • Import CER into Sidekick, which lets you set a password and generate the P12
  • Select the certificate when generating your .mobileprovision in Apple Dev Portal
  • Select the P12 for your Certificate (instead of the pending CSR identity - this part was not clear to me)
  • Select the MOBILEPROVISION for your Provision in the same dialog.

This got me through the cloud build for iOS from Windows. Again, the part that I felt was under-documented was what to change inside Sidekick in between the certificate upload to Apple and the Mobile provision download. If you don’t replace the pending CSR info in Sidekick with the imported CER the rest of the process falls apart.