iOS Question Cannot create Push Keystore

Discussion in 'iOS Questions' started by Shay, Mar 7, 2015.

  1. Shay

    Shay Well-Known Member Licensed User

    <please note the following, after resolved can be used as "how to" document>

    Before writing what errors I get let me say
    I am having trouble understanding the process
    Let's assume I have 2 different apps
    both apps need to use APN for develop and production

    let me explain what I did:
    on first app:
    1. Created 2 IOS certificates, 1 for dev and 1 for production, this created the files:
    ios_development
    ios_distribution

    2. Created app id, choose push notification, from the app id - edit, I created 2 certificates 1 for dev 1 for production. so now in app id I see "green light" for dev and for production.
    this created 2 APS certificates:
    aps_development.cer
    aps_production.cer

    3. Created 2 provision profiles type "APN's" 1 for dev, 1 for production, this created the files:
    App1Dev.mobileprovision
    App1Prod.mobileprovision

    4. I also have
    b4i.p12
    b4i.keystore
    certSigningRequest.csr

    Total 9 files.
    5. on app code I wrote:
    #CertificateFile: ios_development.cer
    #ProvisionFile: App1Dev.mobileprovision
    #If RELEASE
    #CertificateFile: ios_distribution.cer
    #ProvisionFile: App1Prod.mobileprovision
    * I must use ios cer, since getting error if trying to use aps certificates

    6. Compiling debug mode, looks ok
    7. Trying to create "Push Keystore" getting error:
    "There should be exactly one aps certificate file" - WHY?

    8. temporary removing aps_development.cer (not sure if this is ok or not, if so how can it work in debug mode)
    trying again to create "Push Keystore" getting error:
    "error creating key: error: No certificate matches private key" - WHY?

    9. temporary removing aps_production.cer (so how can it work in production mode?)
    trying again to create "Push Keystore" - this is OK
    but will it work on production?

    -------- Second app -------
    1. Changed key folder app to app2

    2. Copied:
    ios_development
    ios_distribution
    b4i.p12
    b4i.keystore
    certSigningRequest.csr

    since as I understand it, the ios certificates is my ios certificates that need to be used on all my apps

    3. created 2 aps, as described above app1 section #2

    4. created 2 provisions, as described above app1 section #3

    5. added code:
    #CertificateFile: ios_development.cer
    #ProvisionFile: App2Dev.mobileprovision

    #If RELEASE
    #CertificateFile: ios_production.cer
    #ProvisionFile: App2Prod.mobileprovision
    #End If

    6. Compiling debug mode, looks ok

    7. temporary removing aps_production.cer OR aps_development.cer as described on app1 section#8, #9

    8. Trying to create "Push Keystore" - getting error on both tries:
    "error creating key: error: No certificate matches private key"

    so I am unable to create "Push Keystore" for second app

    Please address all open questions here

    Thanks
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    There are many small details. I think that it will help you better to understand how the push key is created.

    When you choose the Create Push Keystore option the IDE takes two files:
    1. aps_xxx.cer - The APN SSL certificate file
    2. B4i.p12 - The private key that was created for you when you created the private sign key.

    You must use the same certSigningRequest.csr when you create all the certificates or it will not work.

    The output is: push.keystore.
    The IDE doesn't do anything with this file. It is only required by B4X push server.

    When you want to create a second keystore you need to copy aps_xxx and the push.keystore to a different folder and repeat the previous steps.
     
  3. Shay

    Shay Well-Known Member Licensed User

    I deleted all data from apple site (just left the 2 ios certificates - dev/production)
    created new app id, new provision, new apn, and new provisions based on apn (for each app)
    I can create and install app in debug and release mode for each app
    but still cannot create push keystore
    getting same error: "error creating key: error: No certificate matches private key"
    now both app's cannot create keystore (same error)

    b.t.w which aps certificate I need to leave in directory the dev or the production? (I wish to use push server also for production)
     
  4. Shay

    Shay Well-Known Member Licensed User

    Ok, I manage to solve this:
    1. Deleted all keys from app#1, and also everything on apple site
    2. Created new private key on app#1 (tools --> private sign key)
    3. Created ios certificates, app id, provisional - according to tutorial
    4. Created push aps certificate, explicit app id, push provisional according to push notification tutorial
    5. Checked that I can install app#1 in debug mode, release mode
    6. Created push keystore - was ok

    now moving to app#2
    1. Deleted all keys
    2. Copied from app#1 to app#2: ios certificates, certSigningRequest.csr, b4i* 2 files
    3. Doing section #4,5,6 from above
     
  5. Juan Marrero

    Juan Marrero Active Member Licensed User

    For those who encounter this error using distribution or production provisioning file:
    When you download the aps certificate for production it downloads as "aps.cer". For fixing this just rename this file to aps_production.cer. Then the Create Push Keystore command will work.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    That's true. Currently it looks for aps_*.*

    It is fixed for the next update.
     
    Juan Marrero likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice