简体   繁体   English

主题:在Mac OS X High Sierra的钥匙串访问中无法为gdb的系统证书进行代码签名

[英]subject: cannot codesign system certificate for gdb in keychain access in Mac OS X High Sierra

I'm trying to use gdb on Mac OSX High Sierra. 我正在尝试在Mac OSX High Sierra上使用gdb。 I installed version 8.01 using brew (the latest version 8.1 actually has a separate, unrelated error ), and am having trouble with the codesign step. 我使用brew安装了8.01版(最新版本8.1实际上有一个单独的,不相关的错误 ),并且在codesign步骤上遇到了麻烦。 I'm following the instructions at the page suggested by brew . 我正在按照brew建议页面上说明进行操作

In Keychain Access, I create a certificate, using the "codesign" option, and overriding defaults, and click through until it asks for the location of the certificate, for which I select "keychain: system". 在“钥匙串访问”中,我使用“ codesign”选项创建一个证书,并覆盖默认值,然后单击直到其要求输入证书的位置为止,为此我选择了“钥匙串:系统”。 However, immediately afterwards I get a mysterious message: 但是,此后我立即收到一条神秘消息:

An Error Occurred
Unknown Error = -2,147,414,007

This message also occurred in a previous thread , but the sole answer was of low quality, didn't work, and the question didn't seem to be getting much activity/attention. 该消息也出现在上一个线程中 ,但是唯一的答案是质量低下,没有用,问题似乎并没有引起太多的关注。 I also tried going into recovery mode and doing csrutil disable , but I'm still getting the -2,147,414,007 error. 我还尝试进入恢复模式并执行csrutil disable ,但仍然出现-2,147,414,007错误。 Back in the Keychain Access window, under "System", I get the public and private RSA keys of the certificate I just created, but the certificate itself is not there. 回到“钥匙串访问”窗口中“系统”下,我获得了刚创建的证书的公共和私有RSA密钥,但是证书本身不存在。

If I repeat all that but create under "Login" instead of "System", and this time the certificate gets created. 如果我重复所有操作,但是在“登录”而不是“系统”下创建,那么这次将创建证书。 I then export to a .cer file to my desktop, then import back into Keychains, but under the "System" category. 然后,我将一个.cer文件导出到我的桌面,然后再导入到Keychains中,但在“系统”类别下。 I then restart my computer, then do 然后,我重新启动计算机,然后执行

codesign -s gdb-cert /usr/local/Cellar/gdb/8.0.1/bin/gdb

but I get error: The specified item could not be found in the keychain. 但我收到error: The specified item could not be found in the keychain. .

I can of course just do sudo gdb or lldb with no problem, but I would like to use gdb with emacs , so those are not options (of course, technically I can just do sudo emacs and it will work, but for obvious reasons I prefer not to use sudo ). 我当然可以lldb执行sudo gdblldb ,但我想将gdbemacs一起使用,所以这些都不是选项(当然,从技术上讲,我可以只执行sudo emacs ,它将起作用,但是出于明显的原因,我不希望使用sudo )。 How can I codesign gdb so that I can use it without getting mach port complaints? 我该如何对gdb进行代码签名,以便可以在不遇到mach port投诉的情况下使用它?

edit: it appears another thread elsewhere has many people with the same problem. 编辑:似乎其他地方的另一个线程有很多人有同样的问题。 There doesn't appear to be a definitive fix there; 那里似乎没有确定的解决方法。 I tried some of the suggestions and am continuing to get 我尝试了一些建议,并继续得到

Unable to find Mach task port for process-id 575: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))

I finally got it to work. 我终于得到它的工作。 I'm using the latest High Sierra as of the date of this post. 我正在使用截至本文发布之日的最新High Sierra。 First, I installed an older version of gdb, 8.0.1, instead of the latest 8.1, which seems to be broken : 首先,我安装了较旧的gdb版本8.0.1,而不是似乎已损坏的最新版本8.1:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/9ec9fb27a33698fc7636afce5c1c16787e9ce3f3/Formula/gdb.rb

then brew pin gdb . 然后brew pin gdb

For the next steps, I found this thread , and this other thread useful. 对于后续步骤,我发现此线程该其他线程很有用。 Also, this page . 另外, 此页面

Make the certificate in Login instead of System in order to avoid the -2,147,414,007 error. 为了避免-2,147,414,007错误,请在“登录”而不是“系统”中创建证书。 Then, click the padlock to unlock the System category, and drag the certificate and keys into System. 然后,单击挂锁以解锁“系统”类别,然后将证书和密钥拖动到“系统”中。 If anything goes wrong here, you can try File->Import and File->Export instead. 如果此处出现任何问题,您可以尝试使用File-> Import和File-> Export。 The goal is to get the following: 目标是获得以下内容:

钥匙串访问

eg the certificate and the keys all under the System keychain, not login . 例如证书和密钥都在System钥匙串下,而不是login (It may not even be necessary to drag the keys into system, but I did it just to be safe). (甚至不必将键拖到系统中,但为了安全起见,我这样做了)。

Then, a very important step: right click the certificate, go to Info, Trust, and select Always trust for every category. 然后,这是非常重要的一步:右键单击证书,转到“信息”,“信任”,然后为每个类别选择“始终信任”。 If you don't do this, the codesigning will not be effective, and will still get the mach port error message in gdb, even if you codesign. 如果您不这样做,则代码签名将无效,即使您进行了代码签名,也仍会在gdb中获得马赫端口错误消息。

(One of the answers in the two threads linked above says to temporarily enable the root account in Directory Utilities, but I'm not sure if that's actually necessary). (上面链接的两个线程中的答案之一是说暂时启用Directory Utilities中的root帐户,但我不确定这是否确实必要)。 Then, either restart your computer or do sudo killall taskgated . 然后,重新启动计算机或执行sudo killall taskgated Then codesign -fs gdb-cert $(which gdb) . 然后codesign -fs gdb-cert $(which gdb)

Then, I no longer got the mach port error message in gdb. 然后,我不再在gdb中收到mach端口错误消息。 The first time I ran, I got a popup asking for a password . 我第一次跑时,出现一个弹出窗口,要求输入密码 To disable it for future runs, I did sudo /usr/sbin/DevToolsSecurity --enable as per that thread. 为了禁用它以便以后运行,我按照该线程做了sudo /usr/sbin/DevToolsSecurity --enable

Note also that 8.0.1 has a minor issue: you will get warnings about unhandled dlyd version . 还要注意8.0.1有一个小问题:您将收到有关unhandled dlyd version警告。 That's explained in this thread . 该线程对此进行了解释。 Note some posts in that thread say breakpoints don't work, but I didn't see that happening. 请注意,该线程中的某些帖子说断点不起作用,但我没有看到这种情况。

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

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