Chewie The Chorkie
Chewie The Chorkie

Reputation: 5234

"Warning: unable to build chain to self-signed root for signer" warning in Xcode 9.2

I'm attempting to migrate an Xcode project to another computer. It gives me the warning "Warning: unable to build chain to self-signed root for signer" and when it runs it crashes immediately similarly to what is shown in this Stack Overflow:

App working on simulator but not on iPhone( dyld`__abort_with_payload dyld`_dyld_start)

My issue seems similar to what is described on the Apple Developer Forums here: https://forums.developer.apple.com/thread/86161

and similar to what is described on this Stack Overflow: Xcode ios app development code signing

except the suggestions of deleting certificates and re-adding them, re-adding my account and restarting didn't seem to help. I have removed my developer cert for the second time and now I don't see it coming back, and I'm at a loss of knowing how to get it back since my dev portal doesn't appear to have a place to download it like it used to.

I've also tried deleting the derived data folder several times.

e: I've determined ANY project on this computer results in the same crash and warning.

Upvotes: 115

Views: 92427

Answers (19)

Azure Yu
Azure Yu

Reputation: 407

I have tried a lot of methods, but still it does not work.

Finally, I found that it was because my local time do not match to the system time.

After change the time to the current time, it works!

Hope this is useful!

Upvotes: 0

Paul Hristea
Paul Hristea

Reputation: 1339

If none of the other solutions work, try adding the intermediate signing certificates to your system keychain. I found this while trying to manually create provisioning profile/certificates as nothing else was working - from the Create a New Certificate step of the New Provisioning Profile process on Apple Developer platform:

To use your certificates, you must have the intermediate signing certificate in your system keychain. This is automatically installed by Xcode. However, if you need to reinstall the intermediate signing certificate click the link below:

After downloading these two files and double-clicking them to automatically add to the system keychain, the automatic provisioning profile in xcode started working (I didn't need to complete the manual provisioning profile process, but that's where I found the links)

Edit: There are now 4 files listed there. I assume they should all be double-clicked into the system keychain.

Upvotes: 129

Davut Engin
Davut Engin

Reputation: 895

I've removed my apple id from XCode->Settings->Accounts and add it again, it solved my problem.

Upvotes: 0

Eli Blokh
Eli Blokh

Reputation: 12293

If none of the suggested solutions worked (as in my case), make sure that you put the WWDR Intermediate Certificate into your System keychain, not in login.

Upvotes: 0

Tejas Sharma
Tejas Sharma

Reputation: 170

If anyone is here for Electron related signing related to Mac & Apple, something fixed it for me but I'm not sure what it was:

  • I had 2 Apple Worldwide certificates, deleted the one that expired the soonest
  • I gave permission to my dist/main file via chmod
  • I opened XCode and opened up another iOS project I had. I think this seems the likely fix as it probably updated my certificates

Then when I used electron-builder again, it worked

Upvotes: 0

Huang Huang
Huang Huang

Reputation: 316

It work for me:

macbook air,m1 2020

  1. delete old root CA(if existed): Apple Worldwide Developer Relations Certification Authority
  2. reinstall root CA from certificateauthority,and double click to intall.
  3. reinstall yourself cer. example: Apple Development: XXX Tang (9DHXXX87D)

Upvotes: 0

Keshav
Keshav

Reputation: 3273

I had the same problem and fixed with below steps:

  1. Open Keychain Access
  2. Select login, and click Certificates
  3. Double click Apple Worldwide Developer Relations Certificate Authority
  4. Expand the trust section, then next to "When using this certificate", change the setting from "Always Trust" to "Use System Defaults"
  5. Clean the build folder and run

Upvotes: 109

wanted
wanted

Reputation: 95

1.open xcode-> Preferences-> Accounts

2.select you appleid and click on Manage Certificates

3.click + (Add) and select Apple Development

  1. Clean Build Folder and run project

Upvotes: 3

Klaasel
Klaasel

Reputation: 461

In my case I had an automatically signed project and my own developer certificate was not trusted (anymore) which was apparent in Keychain > login > certificates. On my own certificate I put Always trust in the Get Info popup.

After that I had to select again the "Automatically manage signing" in the Signing & Capabilities tab, which gave an error like "Repair trust settings". After clicking that it fixed the trust of my developer CA.

Also when it was again broken after this, I copied the G3 Apple Worldwide Developer Relations CA from the login keychain (default keychain) to the System Keychain (System).

Upvotes: 2

matthewv789
matthewv789

Reputation: 99

In addition to the other answers, make sure that if you are sudoed to root, exit out before you try to codesign, so that you are signing as the login user. My codesign was failing when I forgot that I was running as root.

Upvotes: 0

Ted
Ted

Reputation: 23746

In the machine where you created the certificate

  1. Open keychain
  2. Look for "Apple Worldwide Developer Relations Certificate Authority"
  3. Look at the column "Expires" and check apple.com/CertificateAuthority to see which has the same expiration

In your ci

  1. Install this certificate to your system keychain

    a. via fastlane

    import_certificate(
      certificate_path: "~/Downloads/AppleWWDRCAG3.cer"
    )
    

    b. via cli

    sudo security import ~/Downloads/AppleWWDRCAG3.cer \
    -k /Library/Keychains/System.keychain \
    -T /usr/bin/codesign \
    -T /usr/bin/security \
    -T /usr/bin/productbuild
    

Upvotes: 5

Dwigt
Dwigt

Reputation: 1059

On Xcode 13.1 and received this error when attempting to archive my app, despite it building fine on the simulator. I didn’t have to change anything with my certificates in the keychain, just cleaning the build folder worked for me.

  1. Open “Product” menu
  2. Select “Clean Build Folder”
  3. Build / Archive your app

I’ve seen some other answers reference which certificates they’ve had, so I’ll just add that I also have the 2030 “Apple Worldwide Developer Relations Certification Authority” cert and the old one is still in my keychain as well, which I’ll probably need to delete at some point.

Upvotes: 1

Timofey Solonin
Timofey Solonin

Reputation: 1403

In my case the error was only resolved after I deleted Apple Worldwide Developer Relations Certification Authority which expires in 2023 from both System and login keychains and imported the other certificate that is valid until 2030. It seems that codesign was picking the incorrect one when both were present in the keychain.

Upvotes: 25

Princekin
Princekin

Reputation: 754

1.change the certificate trust: "Always Trust" ==> "Use System Defaults"

2.change "codesign" command ==> "sudo codesign" command

3.change the "Apple Worldwide Developer Relations Certificate Authority" certificate in login and system items trust: "Always Trust" ==> "Use System Defaults"

worked for me when use codesign command in command line

Upvotes: 6

Wimukthi Rajapaksha
Wimukthi Rajapaksha

Reputation: 1019

none of those actually worked for me. I had to delete the derived data; link, remove all the certificates and reinstall them, clean cache and had to reinstall pod files. After messing around for few hours I found a proper solution.

Upvotes: 1

persec10000
persec10000

Reputation: 1065

I could fix the issue by downloading a new certificate from here and installing it. Look at https://developer.apple.com/de/support/expiration/ for more detail.

Upvotes: 19

kuhr
kuhr

Reputation: 602

@waaheeda's answer led me in the right direction to fix this.

I have a keychain in my repo which is used for signing on my CI. After renewing my iOS enterprise distribution certificate and provisioning profile and updating the keychain accordingly, my CI signing stopped working. Code signing worked locally on my own machine.

I suddenly stumbled upon this and found this part particular interesting:

Enterprise iOS Distribution Certificates generated after September 2, 2020 require the new intermediate certificate installed on any machines that will be code signing.

I therefore found the "Apple Worldwide Developer Relations Intermediate Certificate Expiration" in my local "login" keychain in Keychain Access and added it to the keychain in my repo, and it seems to have fixed the signing for now (and hopefully until 2030):

enter image description here

Upvotes: 9

Vahida Havaldar
Vahida Havaldar

Reputation: 524

This is too late to answer , but if anybody still looking for solution on this thread --

this happens if you are installing certificate for the first time or installing certificate which is created on another machine

In your Xcode project go to signing capabilities enter correct bundle identifier, disable automatic signing , select appropriate profile / import / download profile

then you will find trust repair option below profile , tap on it tap on trust enter your login credentials

this will create and install following certificates

enter image description here

Upvotes: 5

Euros
Euros

Reputation: 102

I have been facing same issue for days now. Finally i solved it by just changing my root CA from Key Chain Access. View in System/ Login key chains. which certificate authority is being used as signer for your personal provisioning profile's certificate. Enter a valid CA certificate and you are good to go! Hope it helps. Ciao!

Upvotes: 7

Related Questions