mailx: nss-config-dir=/etc/pki/nssdb/: 没有这样的文件或目录

mailx: nss-config-dir=/etc/pki/nssdb/: 没有这样的文件或目录

我正在尝试使用发送mailx电子邮件远程 SMTP 服务器(在我的例子中是office365 SMTP服务器)。

这是命令:

# echo "THis is the Body of the email"  | mailx -v -s "This is email subject" -S smtp-use-starttls -S ssl-verify=ignore  -S smtp-auth=login -S smtp=smtp://smtp.office365.com:587 -S [email protected] -S [email protected] -S smtp-auth-password=user_password [email protected] -S nss-config-dir="/etc/pki/nssdb/"

它失败并出现以下错误:

nss-config-dir=/etc/pki/nssdb/: No such file or directory
"/root/dead.letter" 11/339
Resolving host smtp.office365.com . . . done.
Connecting to 132.245.80.146 . . . connected.
220 BY2PR02CA0047.outlook.office365.com Microsoft ESMTP MAIL Service ready at Wed, 5 Nov 2014 10:08:22 +0000
>>> EHLO ip-10-0-1-10.us-west-2.compute.internal
250-BY2PR02CA0047.outlook.office365.com Hello [54.201.139.35]
250-SIZE 78643200
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250 CHUNKING
>>> STARTTLS
220 2.0.0 SMTP server ready
Missing "nss-config-dir" variable.
"/root/dead.letter" 11/339
. . . message not sent.

所以真正的错误是nss-config-dir=/etc/pki/nssdb/: No such file or directory

现在,我确实有一个很好的目录,其中包含必要的证书和密钥,nss-config-dir如下所示:

# ls -ld /etc/pki/nssdb/
drwxr-xr-x. 2 root root 4096 Aug 13  2013 /etc/pki/nssdb/

# ls -ltr /etc/pki/nssdb/
total 124
-rw-r--r--. 1 root root 65536 Jan 12  2010 cert8.db
-rw-r--r--. 1 root root 16384 Jan 12  2010 secmod.db
-rw-r--r--. 1 root root  9216 Jan 12  2010 cert9.db
-rw-r--r--. 1 root root 11264 Jan 12  2010 key4.db
-rw-r--r--. 1 root root 16384 Jan 12  2010 key3.db
-rw-r--r--. 1 root root   451 Jan  9  2013 pkcs11.txt

nss-config-dir以下是有关来自 的信息man mailx

      A  directory  that contains the files certN.db to retrieve certificates, keyN.db to retrieve private keys, and secmod.db, where N is a digit.
      These are usually taken from Mozilla installations, so an appropriate value might be  ‘~/.mozilla/firefox/default.clm’.   Mailx  opens  these
      files  read-only  and  does  not  modify  them.   However,  if the files are modified by Mozilla while mailx is running, it will print a ‘Bad
      database’ message.  It may be necessary to create copies of these files that are exclusively used by mailx then.  Only applicable  if  S/MIME
      and SSL/TLS support is built using Network Security Services (NSS).

我也有SElinux残疾人:

# sestatus
SELinux status:                 disabled

问题:

为什么mailx命令说nss-config-dir=/etc/pki/nssdb/: No such file or directory为什么我有必要的目录和密钥/证书文件?

这是我的环境信息:

# uname -a
Linux ip-10-0-1-10.us-west-2.compute.internal 2.6.32-358.14.1.el6.x86_64 #1 SMP Mon Jun 17 15:54:20 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux

# lsb_release -a
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 6.4 (Santiago)
Release:        6.4
Codename:       Santiago

# rpm -qa | grep mailx
mailx-12.4-6.el6.x86_64

答案1

我建议失败的根本原因是您附加了-S nss-config-dir="/etc/pki/nssdb/"设置收件人传送地址,因此它被视为基于文件的传送目标。

strace您可以在答案中提供的输出中看到这一点:

stat("nss-config-dir=/etc/pki/nssdb/", 0x7fff7073a310) = -1 ENOENT (No such file or directory)

请注意,正在stat尝试访问名为 的文件nss-config-dir=/etc/pki/nssdb/,而不是目录/etc/pki/nssdb/

尝试将您的收件人地址放在列表的末尾,如下所示

echo "This is the body of the email" |
mailx -v -s "This is email subject" \
    -S smtp-use-starttls \
    -S ssl-verify=ignore \
    -S smtp-auth=login \
    -S smtp=smtp://smtp.office365.com:587 \
    -S [email protected] \
    -S [email protected] \
    -S smtp-auth-password=user_password \
    -S nss-config-dir="/etc/pki/nssdb/" \
    [email protected]

答案2

我不知道问题是什么。在乌班图12.04我尝试了上面的命令没有 nss-config-dir选项并且效果很好。这是命令:

# echo "THis is the Body of the email"  | mailx -v -s "This is email subject" -S smtp-use-starttls -S ssl-verify=ignore  -S smtp-auth=login -S smtp=smtp://smtp.office365.com:587 -S [email protected] -S [email protected] -S smtp-auth-password=user_password [email protected]

我不知道为什么它在 RHEL 上不起作用。我strace在 RHEL 上运行了这个命令,但无法找出问题所在。strace给出了以下消息:

stat("nss-config-dir=/etc/pki/nssdb/", 0x7fff7073a310) = -1 ENOENT (No such file or directory)

我不知道为什么这个目录根本没有被检测到,即使在strace:(

此外,在 RHEL 上,省略nss-config-dir不是一个选项,因为该命令将立即失败并出现以下错误:

Missing "nss-config-dir" variable.
"/root/dead.letter" 11/346
. . . message not sent.

但是,在 Ubuntu 上nss-config-dir不需要,并且该命令运行良好。

不管怎样,我要结束这个话题了,因为我可以在 Ubuntu 下生存。

答案3

MS 的 TLS 实现存在缺陷。

我能够使用 Stunnel 和以下配置数据克服它:

[office365-smtp]
client = yes
accept = 192.168.100.25:25
connect = my-personal-id.protection.outlook.com:25
protocol = smtp
verify = 2
CAfile = ca-cert.pem
checkHost = my-personal-id.protection.outlook.com

相关内容