简体   繁体   English

Xcode ios 应用开发代码签名

[英]Xcode ios app development code signing

When I run my app into my iphone I have this Warning:当我在我的 iphone 中运行我的应用程序时,我有这个警告:

unable to build chain to self-signed root for signer "".

My application Installed in iphone but it closed suddenly.我的应用程序安装在 iphone 中,但它突然关闭。

In my case,就我而言,

1- Open Keychain Access 1- 打开钥匙串访问

2- Select login, and click Certificates 2- 选择登录,然后单击证书

3- Double click Apple Worldwide Developer Relations Certificate Authority 3- 双击 Apple Worldwide Developer Relations 证书颁发机构

4- Open trust section, and set to "Use System Defaults" from "Always Trust" 4-打开信任部分,并从“始终信任”设置为“使用系统默认值”

5- Clean build folder and run 5-清理构建文件夹并运行

I too had the same error unable to build chain to self-signed root for signer...我也遇到了同样的错误, unable to build chain to self-signed root for signer...

My mistake was that I had changed the trust setting of my distribution / developer cert to always trust .我的错误是我将发行版/开发者证书的信任设置更改为always trust When I changed it back to Use system Default it all worked.当我将其改回Use system Default ,一切正常。

I had the same problem and basically did like posted in the comment:我遇到了同样的问题,基本上就像在评论中发布的一样:

  • Remove my account at Xcode / Preferences at the top right.在右上角的 Xcode / Preferences 中删除我的帐户。
  • open keychain.打开钥匙扣。 At the left "my certificates": Delete the Mac or iPhone etc Developer certificate.在左侧“我的证书”:删除 Mac 或 iPhone 等开发者证书。
  • just starting Xcode again and creating a new account like one did when starting Xcode for the first time.只是再次启动 Xcode 并创建一个新帐户,就像第一次启动 Xcode 时所做的那样。
  1. Change your trust settings of your developer certificate in keychain access to system default将钥匙串访问中开发人员证书的信任设置更改为系统默认值
  2. Delete all certificates in your local keychain删除本地钥匙串中的所有证书
  3. Quit and relaunch xcode退出并重新启动 xcode
  4. Clean清洁
  5. Run program on device在设备上运行程序
  6. When it asks, enter your keychain password and click always trust当它询问时,输入您的钥匙串密码并单击始终信任

The issue could be having your certificate set to always trust, that's the issue I had.问题可能是将您的证书设置为始终信任,这就是我遇到的问题。 If you're getting this warning that stops you from running apps on your device, this should fix everything.如果您收到此警告,阻止您在设备上运行应用程序,这应该可以解决所有问题。

I saw other answers and attempted to delete my intermediate keychains and root certificate.我看到了其他答案并试图删除我的中间钥匙串和根证书。 But Apple doesn't allow to remove Root certs unless you're in recovery mode and I didn't want to try that.但是 Apple 不允许删除 Root 证书,除非您处于恢复模式并且我不想尝试这样做。 Likely you don't have to delete anything either as this solution works without it.可能您也不必删除任何内容,因为此解决方案没有它就可以工作。

I just thought I'd add an image to clarify things.我只是想我会添加一个图像来澄清事情。 I ran into this issue when I was poking around in my Keychain and accidentally changed the default settings.当我在钥匙串中闲逛时不小心更改了默认设置时遇到了这个问题。

Identifying the bad certificate:识别不良证书:

  1. From you Keychains select Login从您的钥匙扣中选择登录
  2. From Category select Certificates从类别选择证书
  3. Find any Apple Certificate that has the blue + like查找任何带有蓝色+ 的Apple证书,例如
  4. Double click on the certificate.双击证书。 You'll see it look like this你会看到它看起来像这样

在此处输入图片说明

  1. Expand the Trust.扩大信托。 You'd see something like this:你会看到这样的事情:

在此处输入图片说明

  1. If it's messed up then the "When using this certificate" is set to "Always Trust" along with the blue如果它搞砸了,那么“使用此证书时”将与蓝色一起设置为“始终信任”

Fixing the bad certificate:修复错误的证书:

  1. Just set it to "Use System Defaults" and close it.只需将其设置为“使用系统默认值”并关闭它。
  2. You'll get a pop up.你会得到一个弹出窗口。 Type in your password to update settings.输入您的密码以更新设置。
  3. Close KeyChain.关闭钥匙串。 Go back to your project, clean and run.回到你的项目,清理并运行。 Problem should have gone away.问题应该消失了。
  4. If that didn't work then go back to Keychain and just double check and see if there are any other Apple certificates that are set to Always Trust and repeat the process.如果这不起作用,则返回 Keychain 并仔细检查并查看是否有任何其他 Apple 证书设置为Always Trust并重复该过程。

在此处下载更新的证书: https : //developer.apple.com/support/expiration/

After days of trying to find a consistent way, here is the solution:经过几天的努力寻找一致的方式,这里是解决方案:

Xcode 12.4 Xcode 12.4

It seems like a hack but it works!这似乎是一个黑客,但它的工作原理!

  1. Go to Xcode Preferences menu ( command + , ) and then Accounts tab转到 Xcode Preferences菜单( command + , ),然后是Accounts选项卡

  2. click on the gear icon on the bottom left and Export Apple ID and Code Signing Assets...单击左下角的齿轮图标并导出 Apple ID 和代码签名资产...设置

  3. Set a password for the export设置导出密码

⚠️ You are going to delete all passwords and profiles! ⚠️您将删除所有密码和个人资料! Don't forget your password!不要忘记您的密码! Writing down your password is highly recommended.强烈建议写下您的密码。

⛔️ This file will contain all your accounts and profiles. ⛔️ 此文件将包含您的所有帐户和个人资料。 Make sure to keep it very secure.确保保持它非常安全。

  1. Delete all accounts.删除所有帐户。

  2. Build and face the new error.构建并面对新的错误。

  3. Import them back using your password.使用您的密码将它们导入回来。

🎉 It's working again. 🎉它又开始工作了。

如果您能够在调试模式下安装应用程序,则您正在使用分发证书而不是开发证书,但安装完成后它会自动关闭。

One of the way to resolve IOS Codesigning issue is follow following Document.解决 IOS 编码问题的方法之一是遵循以下文档。

iOS Code Signing Troubleshooting iOS 代码签名疑难解答

And Run the following command to know the excact issue并运行以下命令以了解确切问题

spctl -a -t exec -vv <app-path>

One More Tip再一贴

After changing anything in system always clean & build your project to know if solution got applied successfully or not.更改系统中的任何内容后,请始终清理并构建您的项目,以了解解决方案是否成功应用。

It is also important to note that the physical device you are trying to deploy to must be listed in the allowed devices list for that provisioning profile -> you can see this here in the tooltip that pops up from your cert information -> you want to make sure that your device is listed in the "Devices" section.同样重要的是要注意,您尝试部署到的物理设备必须列在该配置文件的允许设备列表中 -> 您可以在从您的证书信息弹出的工具提示中看到这一点 -> 您想要确保您的设备列在“设备”部分。

You can add / remove devices when you create the provisioning profile on the apple developer portal website.您可以在 Apple 开发者门户网站上创建配置文件时添加/删除设备。

Cert popup证书弹出窗口

Xcode 12.4 Xcode 12.4

xcode -> preferences -> accounts -> select the account -> manage certificate -> click on the + icon on the bottom left of the popup window -> ios development xcode->首选项->账户->选择账户->管理证书->点击弹窗左下角的+图标->ios开发

THen you will see a new certificate created.然后您将看到创建了一个新证书。 Now you can run your app.现在您可以运行您的应用程序。

After struggling one day with many answer on forum.经过一天在论坛上的许多答案中挣扎。 I came up with solution works for me.我想出了适合我的解决方案。 below are steps for fix:以下是修复步骤:

  1. Download below certificate from apple PKI official site https://www.apple.com/certificateauthority/从苹果 PKI 官方网站https://www.apple.com/certificateauthority/下载以下证书
Root Certificate Apple Inc. Root Apple Root CA - G3 Root
 Intermediate Certificate Worldwide Developer Relations - G1 (Expiring 02/07/2023 21:48:47 UTC) Worldwide Developer Relations - G3 (Expiring 02/20/2030 00:00:00 UTC)
  1. Download all Certificate and profiles, extension profile specific to your app for development and distribution.下载所有证书和配置文件,特定于您的应用程序的扩展配置文件以进行开发和分发。
  2. Go to Xcode Preferences menu (command+,) and then Accounts tab.转到 Xcode Preferences 菜单(command+,),然后转到 Accounts 选项卡。 Delete all account删除所有账户
  3. Quit Xcode退出 Xcode
  4. Open Key chain and go to login section of Certificate tab打开钥匙链并转到证书选项卡的登录部分
  5. Remove all root and intermediate certificates, Developer ID Certification Authority from key chain.从密钥链中删除所有根证书和中间证书、开发人员 ID 证书颁发机构。
  6. Remove all your app specific certificate删除所有应用程序特定证书
  7. Open finder, go to location (shift+cmd + g) ~/Library/MobileDevice/Provisioning\\ Profiles and remove all certificate打开查找器,转到位置 (shift+cmd + g) ~/Library/MobileDevice/Provisioning\\ Profiles 并删除所有证书
  1. Relaunch Keychain and go to login section of Certificate tab重新启动钥匙串并转到证书选项卡的登录部分
  2. Drag drop root certificates to keychain (root certificate will be trusted automatically do not make it manually )将根证书拖放到钥匙串中(根证书将被自动信任,不要手动创建)
  3. Drag drop intermediate certificates to keychain将中间证书拖放到钥匙串
  4. Drag drop app specific certificate (.p12) to keychain将应用程序特定证书 (.p12) 拖放到钥匙串
  1. Open finder, go to location (shift+cmd + g) ~/Library/MobileDevice/Provisioning\\ Profiles and add you app specific profiles.打开查找器,转到位置 (shift+cmd + g) ~/Library/MobileDevice/Provisioning\\ Profiles 并添加您的应用程序特定配置文件。 Optionally you can login with apple account in Xcode setting and download manually for each profile.或者,您可以在 Xcode 设置中使用 Apple 帐户登录并为每个配置文件手动下载。
  2. Open Xcode and clean derive data (Shift+ Alt+ cmd+ k), and build it with any device.打开 Xcode 并清理派生数据(Shift+Alt+cmd+k),并使用任何设备构建它。

This issue happens due to apple has introduced new root certificate and intermediate certificate.出现此问题是由于苹果引入了新的根证书和中间证书。 Read more detail from https://developer.apple.com/support/wwdr-intermediate-certificate/https://developer.apple.com/support/wwdr-intermediate-certificate/阅读更多详细信息

对我来说,只需在 Xcode 中执行Product > Clean Build Folder就足以解决这个问题。

I'm adding the solution that fixed it for me, and is already on that thread我正在添加为我修复它的解决方案,并且已经在那个线程

The key issue here is the root certificate这里的关键问题是根证书

Export and delete from login/certificate the certifictes named " Apple Worldwide Developer Relations Certification Authority " in your Keychain.导出并从登录/证书中删除钥匙串中名为“ Apple Worldwide Developer Relations Certification Authority ”的证书。

Do the same from system/certificate .system/certificate执行相同的操作。

Import in system/certificate only ONE "Apple Worldwide Developer Relations Certification Authority".仅在系统/证书中导入一个“Apple Worldwide Developer Relations Certification Authority”。 I imported the one that has the expiration date set to 2030 (not 2023).我导入了过期日期设置为 2030 年(不是 2023 年)的那个。

You can also download the latest from: https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer您还可以从以下位置下载最新版本: https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer

That's all.就这样。 But again, make sure it is in your Keychain's SYSTEM and you ONLY have ONE root certificate in your Keychain's SYSTEM area, AND NONE in LOGIN area.但同样,请确保它在您的钥匙串的 SYSTEM 中,并且您的钥匙串的 SYSTEM 区域中只有一个根证书,而在 LOGIN 区域中没有。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM