如何从命令行构建 Safari 扩展包?

发布于 2024-09-13 08:17:40 字数 364 浏览 2 评论 0原文

而不是去 Extension Builder >构建包...,我想从 MyExtension.safariextension 文件夹构建一个 .safariextz 包。

我知道我可以使用 xar -xf 解压扩展。我怀疑返回的方式涉及使用 xar 打包它,但随后我需要进行代码签名,这可能涉及也可能不涉及 codesign(1)

Instead of going to Extension Builder > Build Package…, I'd like to built a .safariextz package from the MyExtension.safariextension folder.

I know I can unpack an extension with xar -xf. I suspect the way back involves packing it with xar, but then I'll need to do the code signing thing, which may or may not involve codesign(1).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼睛会笑 2024-09-20 08:17:40

以下是 Omar Ismail 的说明,省略了单独的 shell 脚本的需要。这一切都将发生在目录 safari/ 中,我们将在其中对目录 safari/appname.safariextension/ 进行签名,使其成为扩展 safari/appname.safariextz< /代码>。第一件事是使用扩展构建器的构建包以官方方式对扩展进行签名。

设置 Xar:
1.下载并解压/untar
https://github.com/downloads/mackyle/xar/xar-1.6.1。 .tar.gz
到任何你想要可执行文件 xar-1.6.1 的地方(xar 1.6dev 不支持我们需要的选项)
2.在xar-1.6.1/中

./configure
make
sudo make install
sudo ln -s /full/path/to/xar-1.6.1/src/xar /usr/local/bin/xar161

设置你的证书:
1. 在 safari/

mkdir certs/
xar161 -f appname.safariextz --extract-certs certs/

2. 打开“钥匙串访问”并将您的 Safari 开发者证书导出到 safari/certs/certs.p12(对 certs.p12 使用空白密码,然后使用 Mac 的密码导出证书)
3. 在 safari/certs/ 中,

openssl pkcs12 -in certs.p12 -nodes | openssl x509 -outform der -out cert.der
(same blank password)
openssl pkcs12 -in certs.p12 -nodes | openssl rsa -out key.pem
(same blank password)
openssl dgst -sign key.pem -binary < key.pem | wc -c > size.txt

您可以从 certs/cert.p12 获取证书,而不需要 --extract-certs 步骤(因此不需要需要以官方方式构建扩展),但我对 openssl 不太了解,而且这只是为了您需要该步骤的设置。

一切设置完毕后,签署扩展程序:
在 safari 中/

xar161 -czf appname.safariextz --distribution appname.safariextension/
xar161 --sign -f appname.safariextz --digestinfo-to-sign digest.dat --sig-size `cat certs/size.txt` --cert-loc certs/cert.der --cert-loc certs/cert01 --cert-loc certs/cert02
openssl rsautl -sign -inkey certs/key.pem -in digest.dat -out sig.dat
xar161 --inject-sig sig.dat -f appname.safariextz
rm -f sig.dat digest.dat

这一切都是在 2006 Snow Leopard MacBook 上进行的,因此在更新的计算机上情况可能会有所不同。

Here are Omar Ismail's instructions, omitting the need for separate shell scripts. This will all occur in a directory safari/, where we will be signing the directory safari/appname.safariextension/ to become the extension safari/appname.safariextz. The first thing is to sign the extension the official way, with Extension Builder's Build Package.

Set up Xar:
1. Download and unzip/untar
https://github.com/downloads/mackyle/xar/xar-1.6.1.tar.gz
to wherever you want the executable xar-1.6.1 (xar 1.6dev doesn't support the options we need)
2. in xar-1.6.1/

./configure
make
sudo make install
sudo ln -s /full/path/to/xar-1.6.1/src/xar /usr/local/bin/xar161

Set up your certificates:
1. in safari/

mkdir certs/
xar161 -f appname.safariextz --extract-certs certs/

2. open Keychain Access and export your Safari Developer certificate to safari/certs/certs.p12 (use a blank password for certs.p12, and then use your Mac's password to export the cert)
3. in safari/certs/

openssl pkcs12 -in certs.p12 -nodes | openssl x509 -outform der -out cert.der
(same blank password)
openssl pkcs12 -in certs.p12 -nodes | openssl rsa -out key.pem
(same blank password)
openssl dgst -sign key.pem -binary < key.pem | wc -c > size.txt

It's possible that you can get the certificates from certs/cert.p12, and not need the --extract-certs step (and hence not need the extension built the official way), but I don't know openssl well enough, and it's only for the set up that you need that step anyway.

Once everything is set up, to sign the extension:
In safari/

xar161 -czf appname.safariextz --distribution appname.safariextension/
xar161 --sign -f appname.safariextz --digestinfo-to-sign digest.dat --sig-size `cat certs/size.txt` --cert-loc certs/cert.der --cert-loc certs/cert01 --cert-loc certs/cert02
openssl rsautl -sign -inkey certs/key.pem -in digest.dat -out sig.dat
xar161 --inject-sig sig.dat -f appname.safariextz
rm -f sig.dat digest.dat

This was all on a 2006 Snow Leopard MacBook, so it's possible things may be different on a machine that's more up to date.

浮云落日 2024-09-20 08:17:40

看起来有一种方法可以使用签名选项来修补 XAR。 http://code.google.com/p/xar/问题/详细信息?id=76#c0

Looks like there is a way to patch XAR with a signature option. http://code.google.com/p/xar/issues/detail?id=76#c0

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文