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에서는 왜 작동하지 않는지 모르겠습니다. RHEL에서 이 명령을 실행 했지만 strace문제를 파악할 수 없었습니다. 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명령이 제대로 작동합니다.

어쨌든 우분투 하에서는 살아남을 수 있기 때문에 이번 주제는 마치겠습니다.

답변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

관련 정보