Accreditamento SDICoop: configurazione SSL su Apache

Salve,
mi sto occupando di creare per la mia azienda il WebService per la ricezione e trasmissione fatture.
Grazie alle indicazioni trovate nei vari topic sono riuscito a superare l’ostacolo dell’invio delle fatture all’SDICoop, ma in fase di chiamata ai servizi da parte loro ho il problema del solito “javax.net.ssl.SSLHandshakeException: General SSLEngine problem”.
Il certificato è stato caricato sul server, ma dai file di log di Apache viene indicato questo:

[Tue Dec 18 16:58:48.264161 2018] [ssl:info] [pid 6344] AH01914: Configuring server dominio.eu:443 for SSL protocol
[Tue Dec 18 16:58:48.264169 2018] [ssl:trace3] [pid 6344] ssl_engine_init.c(482): Creating new SSL context (protocols: TLSv1, TLSv1.1, TLSv1.2)
[Tue Dec 18 16:58:48.264235 2018] [ssl:trace1] [pid 6344] ssl_engine_init.c(656): Configuring client authentication
[Tue Dec 18 16:58:48.264473 2018] [ssl:debug] [pid 6344] ssl_engine_init.c(1600): AH02209: CA certificate: CN=CA Agenzia delle Entrate,OU=Servizi Telematici,O=Agenzia delle Entrate,C=IT
[Tue Dec 18 16:58:48.264493 2018] [ssl:debug] [pid 6344] ssl_engine_init.c(1600): AH02209: CA certificate: CN=CA Agenzia delle Entrate Test,OU=Servizi Telematici,O=Agenzia delle Entrate,C=it
[Tue Dec 18 16:58:48.264507 2018] [ssl:trace1] [pid 6344] ssl_engine_init.c(724): Configuring permitted SSL ciphers [!aNULL:!eNULL:!EXP:HIGH:!aNULL:!MD5]
[Tue Dec 18 16:58:48.264600 2018] [ssl:debug] [pid 6344] ssl_engine_init.c(843): AH01904: Configuring server certificate chain (1 CA certificate)
[Tue Dec 18 16:58:48.264605 2018] [ssl:debug] [pid 6344] ssl_engine_init.c(390): AH01893: Configuring TLS extension handling
[Tue Dec 18 16:58:48.264728 2018] [ssl:trace3] [pid 6344] ssl_util_ssl.c(332): [dominio.eu:443] SSL_X509_match_name: expecting name 'dominio.eu', NOT matched by ID 'SDI-XXXXXXXXXXX'
[Tue Dec 18 16:58:48.264773 2018] [ssl:debug] [pid 6344] ssl_util_ssl.c(343): AH02412: [dominio.eu:443] Cert does not match for name 'dominio.eu' [subject: CN=SDI-XXXXXXXXXXX,OU=Server,OU=Fatturazione Elettronica,O=Agenzia delle Entrate,C=IT / issuer: CN=CA Agenzia delle Entrate,OU=Servizi Telematici,O=Agenzia delle Entrate,C=IT / serial: 2149D147B21F0B38 / notbefore: Dec 14 16:50:21 2018 GMT / notafter: May 31 11:26:11 2021 GMT]
[Tue Dec 18 16:58:48.264776 2018] [ssl:warn] [pid 6344] AH01909: dominio.eu:443:0 server certificate does NOT include an ID which matches the server name
[Tue Dec 18 16:58:48.264779 2018] [ssl:info] [pid 6344] AH02568: Certificate and private key dominio.eu:443:0 configured from /opt/psa/var/certificates/cert-a9GM4b and /opt/psa/var/certificates/cert-a9GM4b
[Tue Dec 18 16:58:48.336583 2018] [ssl:info] [pid 6345] AH01914: Configuring server dominio.eu:443 for SSL protocol
[Tue Dec 18 16:58:48.336591 2018] [ssl:trace3] [pid 6345] ssl_engine_init.c(482): Creating new SSL context (protocols: TLSv1, TLSv1.1, TLSv1.2)
[Tue Dec 18 16:58:48.336640 2018] [ssl:trace1] [pid 6345] ssl_engine_init.c(656): Configuring client authentication
[Tue Dec 18 16:58:48.336902 2018] [ssl:debug] [pid 6345] ssl_engine_init.c(1600): AH02209: CA certificate: CN=CA Agenzia delle Entrate,OU=Servizi Telematici,O=Agenzia delle Entrate,C=IT
[Tue Dec 18 16:58:48.336913 2018] [ssl:debug] [pid 6345] ssl_engine_init.c(1600): AH02209: CA certificate: CN=CA Agenzia delle Entrate Test,OU=Servizi Telematici,O=Agenzia delle Entrate,C=it
[Tue Dec 18 16:58:48.336915 2018] [ssl:trace1] [pid 6345] ssl_engine_init.c(724): Configuring permitted SSL ciphers [!aNULL:!eNULL:!EXP:HIGH:!aNULL:!MD5]
[Tue Dec 18 16:58:48.337023 2018] [ssl:debug] [pid 6345] ssl_engine_init.c(843): AH01904: Configuring server certificate chain (1 CA certificate)
[Tue Dec 18 16:58:48.337027 2018] [ssl:debug] [pid 6345] ssl_engine_init.c(390): AH01893: Configuring TLS extension handling
[Tue Dec 18 16:58:48.337152 2018] [ssl:trace3] [pid 6345] ssl_util_ssl.c(332): [dominio.eu:443] SSL_X509_match_name: expecting name 'dominio.eu', NOT matched by ID 'SDI-XXXXXXXXXXX'
[Tue Dec 18 16:58:48.337217 2018] [ssl:debug] [pid 6345] ssl_util_ssl.c(343): AH02412: [dominio.eu:443] Cert does not match for name 'dominio.eu' [subject: CN=SDI-XXXXXXXXXXX,OU=Server,OU=Fatturazione Elettronica,O=Agenzia delle Entrate,C=IT / issuer: CN=CA Agenzia delle Entrate,OU=Servizi Telematici,O=Agenzia delle Entrate,C=IT / serial: 2149D147B21F0B38 / notbefore: Dec 14 16:50:21 2018 GMT / notafter: May 31 11:26:11 2021 GMT]
[Tue Dec 18 16:58:48.337223 2018] [ssl:warn] [pid 6345] AH01909: dominio.eu:443:0 server certificate does NOT include an ID which matches the server name
[Tue Dec 18 16:58:48.337228 2018] [ssl:info] [pid 6345] AH02568: Certificate and private key dominio.eu:443:0 configured from /opt/psa/var/certificates/cert-a9GM4b and /opt/psa/var/certificates/cert-a9GM4b

Dai messaggi sembrerebbe che non ci sia corrispondenza tra il Common Name che abbiamo nel nostro certificato e quello che cercano loro per l’handshake, al momento della creazione del certificato (che abbiamo inviato in fase di accreditamento del canale) abbiamo usato come Common Name “SDI-XXXXXXXXXXX” per entrambi. Sarebbe stato necessario usare per il certificato lato server il Common Name “dominio.eu”?

Sono state risolte dal tecnico di netsons, che comunque mi ha spiegato che è un problema di ricezione sul server perché sogei per prima cosa fa una specie di “Hello” di controllo sul server con protocollo TLSv1.0 … quindi va ugualmente abilitato, dopodiché cerca i certificati.
Con tanta pazienza ed un tcpdump, si è risolto l’arcano per poi schiantarmi contro quelli di SSL impossibili da risolvere con cPanel.

Alla fine ho preso un Cloud VPS su netsons con Debian 9, abbiamo installato tutto li, ed ha funzionato al primo colpo.

Grazie, era quello che temevo di dover passare almeno ad una vps magari facendo prima solo il webservice e poi trasferire tutto l’applicativo.

Terminati i test e passati in produzione, riceviamo il seguente errore dai nostri log Apache:

SSL Library Error: 336105650 error:140890B2:SSL routines:SSL3_GET_CLIENT_CERTIFICATE:no certificate returned

ssl_engine_kernel.c(773): Performing full renegotiation: complete handshake protocol (client does support secure renegotiation)

Qualcuno ha avuto errori simili? Grazie a tutti

Ciao stefano, scusa il disturbo, ma per il proxy pass su apache2 come lo hai configurato ?

A noi SDI continua a darci : java.io.IOException: Invalid Proxy Server Response

ma la conf è come la tua… bo :thinking::thinking::thinking:

Mi rispondo (per chi legge):eyes:

ProxyPass : non è altro che un redirect proxy per reindirizzare il server di sogei dopo l’autenticazione ssl.

Questo succede quando la chiamata di sogei va su un server, si autentica e poi viene re-indirizzato sul server dove risiede realmente il servizio.

Ciao MwSpaceLLC,

La direttiva ProxyPass serve per inoltrare (più che reindirizzare) la richiesta al tuo server interno dove si trova il servizio, dopo aver gestito l’autentifica TLS.

L’errore riportato però potrebbe essere un problema interno dello SDI che mi pare di aver visto anche in altri thread su questo forum. Ti consiglio di verificare mediante il log se la chiamata arriva veramente al tuo server.

ciao
s.

Ciao stefano,

Si, esattamente, comunque abbiamo optato per dividere server di invio e ricezione e ora inviamo e riceviamo senza problemi :stuck_out_tongue_winking_eye::stuck_out_tongue_winking_eye:

Una volta passati in produzione c’è un modo per vedere se il servizio di produzione funziona o è necessario aspettare la prima fattura reale?

Salve a tutti,
posso cantare vittoria? Se non ho capito male le notifiche di decorrenza arrivano da sole giusto?

Ciao, come hai settato i certificati? A me ancora non vanno

Che stack usi Mario?

Ciao, ho un server NGINX su cui ho installato ubuntu come sistema operativo.

Io ho integrato tutto in qualche giorno (mentre con SDIFtp abbiamo ancora oggi problemi) usando questo package. Ho una APP Ionic 3, Frontend in VueJS e Backend in Laravel.

Senza generare certificati e metterli nell’host?

No beh, i certificati devi un minimo gestirli. In parte ti vengono dati nel Kit di Test. Mentre i CERT per il client e il server li scarichi da Gestione Canale sotto > Download Files.
Una volta scaricati li devi convertire in .pem con openssh, devi poi concatenare in bundle caentrate.der + CAEntrateTest.der sempre con open SSH.
A quel punto lato Client ti basta richiamarli nella configurazione. Il casino è lato server, ma io l’ho fatto su Apache, per cui su NGINX non saprei.

La parte client mi funziona, è la parte server che mi da errore sull’SSL.
Mi copieresti la tua configurazione apache?

Magari mi salvi

ServerAlias xxxxxxxxxx.com ServerName xxxxxxxxxx.com ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf

	#   SSL Engine Switch:
	#   Enable/Disable SSL for this virtual host.
	SSLEngine on

	#   A self-signed (snakeoil) certificate can be created by installing
	#   the ssl-cert package. See
	#   /usr/share/doc/apache2/README.Debian.gz for more info.
	#   If both key and certificate are stored in the same file, only the
	#   SSLCertificateFile directive is needed.
	SSLCertificateFile	/certs/SDI-02667600189-Server.pem
	SSLCertificateKeyFile /certs/sdi.key


	#   Server Certificate Chain:
	#   Point SSLCertificateChainFile at a file containing the
	#   concatenation of PEM encoded CA certificates which form the
	#   certificate chain for the server certificate. Alternatively
	#   the referenced file can be the same as SSLCertificateFile
	#   when the CA certificates are directly appended to the server
	#   certificate for convinience.
	SSLCertificateChainFile /certs/caentrate.der

	#   Certificate Authority (CA):
	#   Set the CA certificate verification path where to find CA
	#   certificates for client authentication or alternatively one
	#   huge file containing all of them (file must be PEM encoded)
	#   Note: Inside SSLCACertificatePath you need hash symlinks
	#		 to point to the certificate files. Use the provided
	#		 Makefile to update the hash symlinks after changes.
	#SSLCACertificatePath /etc/ssl/certs/
	SSLCACertificateFile /certs/CA_Agenzia_delle_Entrate_all.pem

	#   Certificate Revocation Lists (CRL):
	#   Set the CA revocation path where to find CA CRLs for client
	#   authentication or alternatively one huge file containing all
	#   of them (file must be PEM encoded)
	#   Note: Inside SSLCARevocationPath you need hash symlinks
	#		 to point to the certificate files. Use the provided
	#		 Makefile to update the hash symlinks after changes.
	#SSLCARevocationPath /etc/apache2/ssl.crl/
	#SSLCARevocationFile /etc/apache2/ssl.crl/ca-bundle.crl

	#   Client Authentication (Type):
	#   Client certificate verification type and depth.  Types are
	#   none, optional, require and optional_no_ca.  Depth is a
	#   number which specifies how deeply to verify the certificate
	#   issuer chain before deciding the certificate is not valid.
	SSLVerifyClient optional
	SSLVerifyDepth  5
	SSLStrictSNIVHostCheck off
	#   SSL Engine Options:
	#   Set various options for the SSL engine.
	#   o FakeBasicAuth:
	#	 Translate the client X.509 into a Basic Authorisation.  This means that
	#	 the standard Auth/DBMAuth methods can be used for access control.  The
	#	 user name is the `one line' version of the client's X.509 certificate.
	#	 Note that no password is obtained from the user. Every entry in the user
	#	 file needs this password: `xxj31ZMTZzkVA'.
	#   o ExportCertData:
	#	 This exports two additional environment variables: SSL_CLIENT_CERT and
	#	 SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
	#	 server (always existing) and the client (only existing when client
	#	 authentication is used). This can be used to import the certificates
	#	 into CGI scripts.
	#   o StdEnvVars:
	#	 This exports the standard SSL/TLS related `SSL_*' environment variables.
	#	 Per default this exportation is switched off for performance reasons,
	#	 because the extraction step is an expensive operation and is usually
	#	 useless for serving static content. So one usually enables the
	#	 exportation for CGI and SSI requests only.
	#   o OptRenegotiate:
	#	 This enables optimized SSL connection renegotiation handling when SSL
	#	 directives are used in per-directory context.
	#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
	<FilesMatch "\.(cgi|shtml|phtml|php)$">
			SSLOptions +StdEnvVars
	</FilesMatch>
	<Directory /usr/lib/cgi-bin>
			SSLOptions +StdEnvVars
	</Directory>

	#   SSL Protocol Adjustments:
	#   The safe and default but still SSL/TLS standard compliant shutdown
	#   approach is that mod_ssl sends the close notify alert but doesn't wait for
	#   the close notify alert from client. When you need a different shutdown
	#   approach you can use one of the following variables:
	#   o ssl-unclean-shutdown:
	#	 This forces an unclean shutdown when the connection is closed, i.e. no
	#	 SSL close notify alert is send or allowed to received.  This violates
	#	 the SSL/TLS standard but is needed for some brain-dead browsers. Use
	#	 this when you receive I/O errors because of the standard approach where
	#	 mod_ssl sends the close notify alert.
	#   o ssl-accurate-shutdown:
	#	 This forces an accurate shutdown when the connection is closed, i.e. a
	#	 SSL close notify alert is send and mod_ssl waits for the close notify
	#	 alert of the client. This is 100% SSL/TLS standard compliant, but in
	#	 practice often causes hanging connections with brain-dead browsers. Use
	#	 this only for browsers where you know that their SSL implementation
	#	 works correctly.
	#   Notice: Most problems of broken clients are also related to the HTTP
	#   keep-alive facility, so you usually additionally want to disable
	#   keep-alive for those clients, too. Use variable "nokeepalive" for this.
	#   Similarly, one has to force some clients to use HTTP/1.0 to workaround
	#   their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
	#   "force-response-1.0" for this.
	# BrowserMatch "MSIE [2-6]" \
	#		nokeepalive ssl-unclean-shutdown \
	#		downgrade-1.0 force-response-1.0

</VirtualHost>

vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Grazie, vedo di provare a replicarlo.
Mi sa che la mia key da errore

bho, mi sembra plausibile.

fatemi capire come devo affidare le fatture ad un protocollo compromesso

For security and PCI compliance reasons, our servers don’t negotiate TLSv1.0 connections. You have to use TLS1.1 or TLS1.2 on our infrastructure.
See https://statusblog.webfaction.com/2018/06/04/deprecating-tls-1-0-and-tls_rsa_with_3des_ede_cbc_sha-ciphers/