0

So it turned out that SELinux is causing all the issues I've been having with USPS shipping calculation and Paypal redirecting.

This is my current stack:

  • 2.3.5p1
  • CentOS 8
  • PHP 7.3.18
  • Apache/2.4.37
  • 10.3.17-MariaDB MariaDB

The only SELinux rule exceptions that I have configured are the ones from the setup guide

chcon -R --type httpd_sys_rw_content_t <magento_root>/app/etc
chcon -R --type httpd_sys_rw_content_t <magento_root>/var
chcon -R --type httpd_sys_rw_content_t <magento_root>/pub/media
chcon -R --type httpd_sys_rw_content_t <magento_root>/pub/static
chcon -R --type httpd_sys_rw_content_t <magento_root>/generated

These are the errors that I am seeing trying to checkout with Paypal

type=AVC msg=audit(1591554743.559:10135): avc:  denied  { name_connect } for  pid=3389 comm="httpd" dest=80 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0
type=SYSCALL msg=audit(1591554743.559:10135): arch=c000003e syscall=42 success=no exit=-13 a0=19 a1=7f6a14077238 a2=10 a3=26 items=0 ppid=981 pid=3389 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)ARCH=x86_64 SYSCALL=connect AUID="unset" UID="apache" GID="apache" EUID="apache" SUID="apache" FSUID="apache" EGID="apache" SGID="apache" FSGID="apache"
type=PROCTITLE msg=audit(1591554743.559:10135): proctitle=2F7573722F7362696E2F6874747064002D44464F524547524F554E44
type=AVC msg=audit(1591554743.559:10136): avc:  denied  { name_connect } for  pid=3389 comm="httpd" dest=80 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0
type=SYSCALL msg=audit(1591554743.559:10136): arch=c000003e syscall=42 success=no exit=-13 a0=19 a1=7f6a14077318 a2=10 a3=26 items=0 ppid=981 pid=3389 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)ARCH=x86_64 SYSCALL=connect AUID="unset" UID="apache" GID="apache" EUID="apache" SUID="apache" FSUID="apache" EGID="apache" SGID="apache" FSGID="apache"
type=PROCTITLE msg=audit(1591554743.559:10136): proctitle=2F7573722F7362696E2F6874747064002D44464F524547524F554E44
type=AVC msg=audit(1591554743.559:10137): avc:  denied  { name_connect } for  pid=3389 comm="httpd" dest=80 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0
type=SYSCALL msg=audit(1591554743.559:10137): arch=c000003e syscall=42 success=no exit=-13 a0=19 a1=7f6a140773d8 a2=1c a3=26 items=0 ppid=981 pid=3389 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)ARCH=x86_64 SYSCALL=connect AUID="unset" UID="apache" GID="apache" EUID="apache" SUID="apache" FSUID="apache" EGID="apache" SGID="apache" FSGID="apache"
type=PROCTITLE msg=audit(1591554743.559:10137): proctitle=2F7573722F7362696E2F6874747064002D44464F524547524F554E44
type=AVC msg=audit(1591554743.559:10138): avc:  denied  { name_connect } for  pid=3389 comm="httpd" dest=80 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0
type=SYSCALL msg=audit(1591554743.559:10138): arch=c000003e syscall=42 success=no exit=-13 a0=19 a1=7f6a14077498 a2=1c a3=26 items=0 ppid=981 pid=3389 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)ARCH=x86_64 SYSCALL=connect AUID="unset" UID="apache" GID="apache" EUID="apache" SUID="apache" FSUID="apache" EGID="apache" SGID="apache" FSGID="apache"
type=PROCTITLE msg=audit(1591554743.559:10138): proctitle=2F7573722F7362696E2F6874747064002D44464F524547524F554E44
type=AVC msg=audit(1591554755.101:10139): avc:  denied  { name_connect } for  pid=5556 comm="php-fpm" dest=80 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0
type=SYSCALL msg=audit(1591554755.101:10139): arch=c000003e syscall=42 success=no exit=-13 a0=b a1=7f2e04f71880 a2=10 a3=30ccdaa3dcf68 items=0 ppid=977 pid=5556 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="php-fpm" exe="/usr/sbin/php-fpm" subj=system_u:system_r:httpd_t:s0 key=(null)ARCH=x86_64 SYSCALL=connect AUID="unset" UID="apache" GID="apache" EUID="apache" SUID="apache" FSUID="apache" EGID="apache" SGID="apache" FSGID="apache"
type=PROCTITLE msg=audit(1591554755.101:10139): proctitle=7068702D66706D3A20706F6F6C20777777
type=AVC msg=audit(1591554758.933:10140): avc:  denied  { name_connect } for  pid=5728 comm="php-fpm" dest=80 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0
type=SYSCALL msg=audit(1591554758.933:10140): arch=c000003e syscall=42 success=no exit=-13 a0=b a1=7f2e0555cf50 a2=10 a3=1bd7a524e1bda8 items=0 ppid=977 pid=5728 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="php-fpm" exe="/usr/sbin/php-fpm" subj=system_u:system_r:httpd_t:s0 key=(null)ARCH=x86_64 SYSCALL=connect AUID="unset" UID="apache" GID="apache" EUID="apache" SUID="apache" FSUID="apache" EGID="apache" SGID="apache" FSGID="apache"
type=PROCTITLE msg=audit(1591554758.933:10140): proctitle=7068702D66706D3A20706F6F6C20777777
type=CRYPTO_KEY_USER msg=audit(1591554760.272:10141): pid=6131 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=SHA256:6e:7a:25:0c:d8:c7:96:70:2b:d9:f4:50:da:fc:ad:2a:4e:db:38:38:b3:1d:3b:db:c8:28:18:85:23:e9:80:dc direction=? spid=6131 suid=0  exe="/usr/sbin/sshd" hostname=? addr=? terminal=? res=success'UID="root" AUID="unset" SUID="root"
type=CRYPTO_KEY_USER msg=audit(1591554760.272:10142): pid=6131 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=SHA256:69:e1:51:7d:fc:3f:fb:4f:32:18:9d:77:2f:fa:e9:c5:fd:49:96:a5:a4:9f:53:48:dd:47:a0:39:b9:a6:2b:f9 direction=? spid=6131 suid=0  exe="/usr/sbin/sshd" hostname=? addr=? terminal=? res=success'UID="root" AUID="unset" SUID="root"
type=CRYPTO_KEY_USER msg=audit(1591554760.272:10143): pid=6131 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=SHA256:1b:8a:08:1d:ea:56:57:1e:7f:06:01:1f:9e:cd:4e:88:dd:1b:73:7c:65:cf:2b:df:50:de:41:f7:62:3c:9a:83 direction=? spid=6131 suid=0  exe="/usr/sbin/sshd" hostname=? addr=? terminal=? res=success'UID="root" AUID="unset" SUID="root"
type=CRYPTO_SESSION msg=audit(1591554760.283:10144): pid=6130 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=start direction=from-server cipher=aes128-ctr ksize=128 mac=hmac-sha2-256 pfs=ecdh-sha2-nistp256 spid=6131 suid=74 rport=51959 laddr=167.99.124.211 lport=22  exe="/usr/sbin/sshd" hostname=? addr=222.186.15.158 terminal=? res=success'UID="root" AUID="unset" SUID="sshd"
type=CRYPTO_SESSION msg=audit(1591554760.290:10145): pid=6130 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=start direction=from-client cipher=aes128-ctr ksize=128 mac=hmac-sha2-256 pfs=ecdh-sha2-nistp256 spid=6131 suid=74 rport=51959 laddr=167.99.124.211 lport=22  exe="/usr/sbin/sshd" hostname=? addr=222.186.15.158 terminal=? res=success'UID="root" AUID="unset" SUID="sshd"
type=CRYPTO_KEY_USER msg=audit(1591554761.497:10146): pid=6130 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=destroy kind=session fp=? direction=both spid=6131 suid=74 rport=51959 laddr=167.99.124.211 lport=22  exe="/usr/sbin/sshd" hostname=? addr=222.186.15.158 terminal=? res=success'UID="root" AUID="unset" SUID="sshd"
type=CRYPTO_KEY_USER msg=audit(1591554761.499:10147): pid=6130 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=SHA256:1b:8a:08:1d:ea:56:57:1e:7f:06:01:1f:9e:cd:4e:88:dd:1b:73:7c:65:cf:2b:df:50:de:41:f7:62:3c:9a:83 direction=? spid=6131 suid=74  exe="/usr/sbin/sshd" hostname=? addr=? terminal=? res=success'UID="root" AUID="unset" SUID="sshd"
type=USER_ERR msg=audit(1591554761.499:10148): pid=6130 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=PAM:bad_ident grantors=? acct="?" exe="/usr/sbin/sshd" hostname=222.186.15.158 addr=222.186.15.158 terminal=ssh res=failed'UID="root" AUID="unset"
type=CRYPTO_KEY_USER msg=audit(1591554761.500:10149): pid=6130 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=SHA256:6e:7a:25:0c:d8:c7:96:70:2b:d9:f4:50:da:fc:ad:2a:4e:db:38:38:b3:1d:3b:db:c8:28:18:85:23:e9:80:dc direction=? spid=6130 suid=0  exe="/usr/sbin/sshd" hostname=? addr=? terminal=? res=success'UID="root" AUID="unset" SUID="root"
type=CRYPTO_KEY_USER msg=audit(1591554761.500:10150): pid=6130 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=SHA256:69:e1:51:7d:fc:3f:fb:4f:32:18:9d:77:2f:fa:e9:c5:fd:49:96:a5:a4:9f:53:48:dd:47:a0:39:b9:a6:2b:f9 direction=? spid=6130 suid=0  exe="/usr/sbin/sshd" hostname=? addr=? terminal=? res=success'UID="root" AUID="unset" SUID="root"
type=CRYPTO_KEY_USER msg=audit(1591554761.500:10151): pid=6130 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=SHA256:1b:8a:08:1d:ea:56:57:1e:7f:06:01:1f:9e:cd:4e:88:dd:1b:73:7c:65:cf:2b:df:50:de:41:f7:62:3c:9a:83 direction=? spid=6130 suid=0  exe="/usr/sbin/sshd" hostname=? addr=? terminal=? res=success'UID="root" AUID="unset" SUID="root"
type=USER_LOGIN msg=audit(1591554761.500:10152): pid=6130 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=login acct="root" exe="/usr/sbin/sshd" hostname=? addr=222.186.15.158 terminal=ssh res=failed'UID="root" AUID="unset"
type=AVC msg=audit(1591554842.724:10153): avc:  denied  { name_connect } for  pid=5252 comm="php-fpm" dest=443 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0
type=SYSCALL msg=audit(1591554842.724:10153): arch=c000003e syscall=42 success=no exit=-13 a0=b a1=7fffdf32af30 a2=10 a3=103dacdc20491d items=0 ppid=977 pid=5252 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="php-fpm" exe="/usr/sbin/php-fpm" subj=system_u:system_r:httpd_t:s0 key=(null)ARCH=x86_64 SYSCALL=connect AUID="unset" UID="apache" GID="apache" EUID="apache" SUID="apache" FSUID="apache" EGID="apache" SGID="apache" FSGID="apache"
type=PROCTITLE msg=audit(1591554842.724:10153): proctitle=7068702D66706D3A20706F6F6C20777777
type=AVC msg=audit(1591554850.402:10154): avc:  denied  { name_connect } for  pid=5864 comm="php-fpm" dest=80 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0
type=SYSCALL msg=audit(1591554850.402:10154): arch=c000003e syscall=42 success=no exit=-13 a0=b a1=7f2e071f7950 a2=10 a3=c09c3fd427f11 items=0 ppid=977 pid=5864 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="php-fpm" exe="/usr/sbin/php-fpm" subj=system_u:system_r:httpd_t:s0 key=(null)ARCH=x86_64 SYSCALL=connect AUID="unset" UID="apache" GID="apache" EUID="apache" SUID="apache" FSUID="apache" EGID="apache" SGID="apache" FSGID="apache"
type=PROCTITLE msg=audit(1591554850.402:10154): proctitle=7068702D66706D3A20706F6F6C20777777
type=AVC msg=audit(1591554855.790:10155): avc:  denied  { name_connect } for  pid=5694 comm="php-fpm" dest=80 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0
type=SYSCALL msg=audit(1591554855.790:10155): arch=c000003e syscall=42 success=no exit=-13 a0=b a1=7f2e05b63f50 a2=10 a3=179961253ee69f items=0 ppid=977 pid=5694 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="php-fpm" exe="/usr/sbin/php-fpm" subj=system_u:system_r:httpd_t:s0 key=(null)ARCH=x86_64 SYSCALL=connect AUID="unset" UID="apache" GID="apache" EUID="apache" SUID="apache" FSUID="apache" EGID="apache" SGID="apache" FSGID="apache"
type=PROCTITLE msg=audit(1591554855.790:10155): proctitle=7068702D66706D3A20706F6F6C20777777
type=AVC msg=audit(1591554859.471:10156): avc:  denied  { name_connect } for  pid=5253 comm="php-fpm" dest=80 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0
type=SYSCALL msg=audit(1591554859.471:10156): arch=c000003e syscall=42 success=no exit=-13 a0=b a1=7f2e05beb030 a2=10 a3=e166527d31c08 items=0 ppid=977 pid=5253 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="php-fpm" exe="/usr/sbin/php-fpm" subj=system_u:system_r:httpd_t:s0 key=(null)ARCH=x86_64 SYSCALL=connect AUID="unset" UID="apache" GID="apache" EUID="apache" SUID="apache" FSUID="apache" EGID="apache" SGID="apache" FSGID="apache"
type=PROCTITLE msg=audit(1591554859.471:10156): proctitle=7068702D66706D3A20706F6F6C20777777
type=AVC msg=audit(1591554860.581:10157): avc:  denied  { name_connect } for  pid=5692 comm="php-fpm" dest=80 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0
type=SYSCALL msg=audit(1591554860.581:10157): arch=c000003e syscall=42 success=no exit=-13 a0=b a1=7f2e069f5030 a2=10 a3=115feec4344fa2 items=0 ppid=977 pid=5692 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="php-fpm" exe="/usr/sbin/php-fpm" subj=system_u:system_r:httpd_t:s0 key=(null)ARCH=x86_64 SYSCALL=connect AUID="unset" UID="apache" GID="apache" EUID="apache" SUID="apache" FSUID="apache" EGID="apache" SGID="apache" FSGID="apache"
type=PROCTITLE msg=audit(1591554860.581:10157): proctitle=7068702D66706D3A20706F6F6C20777777
type=AVC msg=audit(1591554861.105:10158): avc:  denied  { name_connect } for  pid=5543 comm="php-fpm" dest=80 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0
type=SYSCALL msg=audit(1591554861.105:10158): arch=c000003e syscall=42 success=no exit=-13 a0=b a1=7f2e04df4030 a2=10 a3=32fbdbc9c0ffd items=0 ppid=977 pid=5543 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="php-fpm" exe="/usr/sbin/php-fpm" subj=system_u:system_r:httpd_t:s0 key=(null)ARCH=x86_64 SYSCALL=connect AUID="unset" UID="apache" GID="apache" EUID="apache" SUID="apache" FSUID="apache" EGID="apache" SGID="apache" FSGID="apache"
type=PROCTITLE msg=audit(1591554861.105:10158): proctitle=7068702D66706D3A20706F6F6C20777777

For anyone else who has installed Magento 2 on a Linux distro with SELinux enabled, what other rule exceptions did you have to add to get shipping and payment to work? Thank you so much in advance. I think this will help out a lot of folks getting the:

[2020-05-30 20:55:26] main.CRITICAL: Report ID: webapi-5ed2c83e06062; Message: cURL error 7:  (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) {"exception":"[object] (Exception(code: 0): Report ID: webapi-5ed2c83e06062; Message: cURL error 7:  (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) at /var/www/html/vendor/magento/framework/Webapi/ErrorProcessor.php:208, Magento\\Framework\\HTTP\\AsyncClient\\HttpException(code: 0): cURL error 7:  (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) at /var/www/html/vendor/magento/framework/HTTP/AsyncClient/GuzzleWrapDeferred.php:88, GuzzleHttp\\Exception\\ConnectException(code: 0): cURL error 7:  (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) at /var/www/html/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:200)"}
0

This is the solution for anyone facing the same issue.

Since the newer versions of CentOS all come with SELinux enabled, we need to adjust the httpd can network connect boolean so that curl can be used.

/usr/sbin/setsebool httpd_can_network_connect 1
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.