现在主流的浏览器都强制要求HTTPS,使用HTTPS加载的页面不能加载来自HTTP的任何内容,并且不能使用Websockets 进行通信。最近配置Aria2的RPC并启用SSL加密时,遇到一个权限问题。问题的日志文件描述如下:

Tue May 12 00:16:57 2020 daemon.err aria2c[19454]: Parse error in /var/etc/aria2/aria2.conf.main
Tue May 12 00:16:57 2020 daemon.err aria2c[19454]: Exception: [AbstractOptionHandler.cc:69] errorCode=28 We encountered a problem while processing the option '--rpc-certificate'.
Tue May 12 00:16:57 2020 daemon.err aria2c[19454]:   -> [OptionHandlerImpl.cc:556] errorCode=1 Could not get file status: Permission denied
Tue May 12 00:16:57 2020 daemon.err aria2c[19454]: Usage:
Tue May 12 00:16:57 2020 daemon.err aria2c[19454]:  --rpc-certificate=FILE       Use the certificate in FILE for RPC server.
Tue May 12 00:16:57 2020 daemon.err aria2c[19454]:                               The certificate must be in PEM format.
Tue May 12 00:16:57 2020 daemon.err aria2c[19454]:                               Use --rpc-private-key option to specify the
Tue May 12 00:16:57 2020 daemon.err aria2c[19454]:                               private key. Use --rpc-secure option to enable
Tue May 12 00:16:57 2020 daemon.err aria2c[19454]:                               encryption.

RPC SSL 相关的配置如下:

rpc-secure=true
rpc-certificate=/etc/uhttpd.crt
rpc-private-key=/etc/uhttpd.key

我反复检查确认过了这两个文件的权限设置,还是没发现问题:

root@cwyyprog:/# ls -l /etc/uhttpd.*
lrwxrwxrwx    1 root     root            54 May 12 00:02 /etc/uhttpd.crt -> /root/.acme.sh/cwyyprog.mydns.jp/cwyyprog.mydns.jp.cer
lrwxrwxrwx    1 root     root            54 May 12 00:02 /etc/uhttpd.key -> /root/.acme.sh/cwyyprog.mydns.jp/cwyyprog.mydns.jp.key
root@cwyyprog:/# ls -l /root/.acme.sh/cwyyprog.mydns.jp/cwyyprog.mydns.jp.cer
-rw-r--r-x    1 root     root          1915 May 12 00:00 /root/.acme.sh/cwyyprog.mydns.jp/cwyyprog.mydns.jp.cer
root@cwyyprog:/# ls -l /root/.acme.sh/cwyyprog.mydns.jp/cwyyprog.mydns.jp.key
-rw-r--r-x    1 root     root          1679 May 11 23:54 /root/.acme.sh/cwyyprog.mydns.jp/cwyyprog.mydns.jp.key

最后经过好一番折腾没有解决才仔细回忆起最初学习Linux系统时,好像对那些权限设置没什么耐心,只看了最开始的文件权限的部分,觉得后面的内容是无关紧要的细枝末节,没有仔细看。只能重新复习下Linux系统的权限管理体系。这次带着问题去看,果然就不一样了,很快就找到原因了。发现Aria2 还需要配置文件的父级和全部祖级目录的可执行权限,也就是X权限。

chmod -R o+x /root/.acme.sh/cwyyprog.mydns.jp 

1 对 “Aria2 的证书权限问题”的想法;

  1. This is just what I need to familiarize myself in this field. Looking forward to many interesting and helpful articles from you. the article is very interesting and effective.

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据