클라이언트 인증을 구성한 후 Apache 서버를 시작할 수 없습니다

클라이언트 인증을 구성한 후 Apache 서버를 시작할 수 없습니다

운영체제 7 |아파치 2.4.6


저는 개인 인증 기관(CA)과 두 개의 인증서(서버용과 클라이언트용)를 구축했습니다.

그런 다음 인증서 X.509를 사용하여 HTTPS 연결에 응답하도록 Apache를 구성했고 모든 것이 잘 진행되었습니다(브라우저에서 확인했습니다).

그런 다음 클라이언트 인증을 구성할 때 서버를 다시 시작하고 다음 오류가 발생합니다.

제어 프로세스가 오류 코드와 함께 종료되었기 때문에 httpd.service 작업이 실패했습니다. 자세한 내용은 "systemctl status httpd.service" 및 "journalctl -xe"를 참조하세요.

이제 "Syntax OK"라고 표시되지만 여전히 서버를 시작할 수 없습니다. 다음 명령을 사용하면 다음 오류가 발생합니다.

. systemctl 상태 httpd.service

[root@localhost ~]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2019-05-01 18:35:40 WEST; 2min 3s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 12292 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 12288 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 12288 (code=exited, status=1/FAILURE)

May 01 18:35:37 src_ca systemd[1]: Starting The Apache HTTP Server...
May 01 18:35:40 src_ca systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
May 01 18:35:40 src_ca kill[12292]: kill: cannot find process ""
May 01 18:35:40 src_ca systemd[1]: httpd.service: control process exited, code=exited status=1
May 01 18:35:40 src_ca systemd[1]: Failed to start The Apache HTTP Server.
May 01 18:35:40 src_ca systemd[1]: Unit httpd.service entered failed state.
May 01 18:35:40 src_ca systemd[1]: httpd.service failed.

."journalctl -xe"

May 01 18:39:16 src_ca polkitd[2607]: Registered Authentication Agent for unix-process:12474:9099194 (system bus name :1.157 [/usr/bin/pkttyagent --notify-fd 5 --fallba
May 01 18:39:16 src_ca systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has begun starting up.
May 01 18:39:18 src_ca systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
May 01 18:39:18 src_ca kill[12483]: kill: cannot find process ""
May 01 18:39:18 src_ca systemd[1]: httpd.service: control process exited, code=exited status=1
May 01 18:39:18 src_ca systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has failed.
--
-- The result is failed.
May 01 18:39:18 src_ca systemd[1]: Unit httpd.service entered failed state.
May 01 18:39:18 src_ca systemd[1]: httpd.service failed.
May 01 18:39:18 src_ca polkitd[2607]: Unregistered Authentication Agent for unix-process:12474:9099194 (system bus name :1.157, object path /org/freedesktop/PolicyKit1/

클라이언트 인증을 구성하는 데 사용한 프로세스는 아래에 남겨두겠습니다. 질문 하단에 유용한 문서를 남겨 두겠습니다.


클라이언트 인증 구성 프로세스

  1. 먼저 "/etc/httpd/conf.d/ssl.conf" 파일에서 "SSLCACertificateFile" 옵션을 찾으십시오.vi +/SSLCACertificateFile /etc/httpd/conf.d/ssl.conf

  2. 경로를 다음으로 업데이트하세요./etc/pki/CA/certs/ca.crt

CA 인증서의 위치입니다.

참고: 클라이언트 인증서는 /etc/pki/CA/certs 폴더에 있습니다. 클라이언트 인증을 구성할 때 이로 인해 문제가 발생하는지 잘 모르겠습니다. (업데이트: 편집 1)

  1. "SSLVerifyClient require" 지시문에서 "#"을 제거했습니다.

  2. 변경 사항을 저장하고 파일을 종료한 :wq후 서버를 다시 시작합니다.systemctl restart httpd


디버깅에 유용한 파일

. "etc/hosts"(IP + 호스트 추가)

등/호스트

. "/etc/hostname"(으로 완성 가능 hostnamectl set-hostname new-hostname)

/etc/호스트 이름

. "etc/httpd/conf/httpd.conf"

등/httpd/conf/httpd.conf

. "/etc/httpd/conf.d/ssl.conf"

/etc/httpd/conf.d/ssl.conf

. "/var/log/httpd/error_log"

[Wed May 01 18:18:13.050768 2019] [core:notice] [pid 11416] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Wed May 01 18:18:13.053282 2019] [suexec:notice] [pid 11416] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[We May 01 18:18:16.238779 2019] [ssl:emerg] [pid 11416] AH02311: Fatal error initialising mod_ssl, exiting. See /etc/httpd/logs/ssl_error_log for more information

. "/var/log/httpd/ssl_error_log"

[Wed May 01 18:18:16.238749 2019] [ssl:emerg] [pid 11416] AH01895: Unable to configure verify locations for client authentication

답변1

다른 컨텍스트에 구축된 인증서를 사용하고 Apache를 다시 시작했는데 오류가 표시되지 않았습니다.

이는 오류가 인증서와 관련되어 있어야 함을 의미합니다.

이를 고려하여 CA를 구축하는 데 사용된 프로세스(이 답변의 하단에 추가하겠습니다)를 자세히 살펴보고 오류를 발견했습니다.

대신 "임시" 인증서를 사용하고 있습니다 cacert.pem.


CA 생성 프로세스:

  1. openssl genrsa -des3 -out /etc/pki/CA/private/cakey.pem

  2. openssl req -new -key /etc/pki/CA/private/cakey.pem -out /etc/pki/CA/ca.crt

  3. openssl x509 -req -days 100 -in ca.crt -out cacert.pem -signkey private/cakey.pem

관련 정보