bonjour,
j'essaie d'envoyer, via curl, un fichier sur un serveur https. Tant que le serveur était en http, aucun soucis. Depuis qu'il est en https, impossible de faire fonctionner curl avec. Curl refuse de reconnaitre le certificat SSL du serveur. Il y a bien l'option '-k' dans curl, mais celle-ci désactive la validation ssl sur serveur, ce qui réduit à 0 la sécurité du ssl, et je voudrais donc l'éviter.
Voilà d'abord le dit serveur, reconnu par défaut par firefox:
J'y suis d'abord allé version naif:
Visiblement, pas de certificat dispo. J'exporte donc le certificat de mon serveur (bouton exporter de firefox). J'obtiens alors un fichier .pem spécifique à serveur.domain, que j'utilise
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 $ curl -v -u user:pass -T /path/to/source.xml https://server.domain/path/to/destination * About to connect() to serveur.domain port 443 (#0) * Trying 193.190.249.140... connected * Connected to serveur.domain (193.190.249.140) port 443 (#0) * error setting certificate verify locations: CAfile: /etc/ssl/certs/ca-certificates.crt CApath: none * Closing connection #0 curl: (77) error setting certificate verify locations: CAfile: /etc/ssl/certs/ca-certificates.crt CApath: none
j'essaie alors avec le .pem de l'autorité qui a signé mon serveur, de nouveau exporé avec firefox:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 $ curl --cacert /tmp/server.domain -v -u user:pass -T /path/to/source.xml https://server.domain/path/to/destination * About to connect() to serveur.domain port 443 (#0) * Trying 193.190.249.140... connected * Connected to serveur.domain (193.190.249.140) port 443 (#0) * successfully set certificate verify locations: * CAfile: /tmp/serveur.domain CApath: none * SSLv2, Client hello (1): * SSLv3, TLS handshake, Server hello (2): * SSLv3, TLS handshake, CERT (11): * SSLv3, TLS alert, Server hello (2): * SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed * Closing connection #0 curl: (60) SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed More details here: http://curl.haxx.se/docs/sslcerts.html curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). The default bundle is named curl-ca-bundle.crt; you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option.
et pas plus de chance avec l'autorité racine
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 $ curl --cacert /tmp/TERENASSLCA -v -u user:pass -T /path/to/source.xml https://serveur.domain/path/to/destination * About to connect() to serveur.domain port 443 (#0) * Trying 193.190.249.140... connected * Connected to serveur.domain (193.190.249.140) port 443 (#0) * successfully set certificate verify locations: * CAfile: /tmp/TERENASSLCA CApath: none * SSLv2, Client hello (1): * SSLv3, TLS handshake, Server hello (2): * SSLv3, TLS handshake, CERT (11): * SSLv3, TLS alert, Server hello (2): * SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed * Closing connection #0 curl: (60) SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed More details here: http://curl.haxx.se/docs/sslcerts.html curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). The default bundle is named curl-ca-bundle.crt; you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option.
un dernier essai en téléchargeant les certificate autorities depuis le site de curl:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 $ curl --cacert /tmp/AddTrustExternalCARoot -v -u user:pass -T /path/to/source.xml https://serveur.domain/path/to/destination * About to connect() to serveur.domain port 443 (#0) * Trying 193.190.249.140... connected * Connected to serveur.domain (193.190.249.140) port 443 (#0) * successfully set certificate verify locations: * CAfile: /tmp/AddTrustExternalCARoot CApath: none * SSLv2, Client hello (1): * SSLv3, TLS handshake, Server hello (2): * SSLv3, TLS handshake, CERT (11): * SSLv3, TLS alert, Server hello (2): * SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed * Closing connection #0 curl: (60) SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed More details here: http://curl.haxx.se/docs/sslcerts.html curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). The default bundle is named curl-ca-bundle.crt; you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option.
Alors la question fondamentale, qu'est-ce que je rate dans la doc à ce sujet? Qu'est-ce qu'il me manque??
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 $ wget http://curl.haxx.se/ca/cacert.pem -O /tmp/fullcacert.pem --11:28:07-- http://curl.haxx.se/ca/cacert.pem => `/tmp/fullcacert.pem' Resolving curl.haxx.se... 80.67.6.50 Connecting to curl.haxx.se|80.67.6.50|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 252,513 (247K) [text/plain] 100%[======================================================================================================================>] 252,513 1.10M/s 11:28:07 (1.09 MB/s) - `/tmp/fullcacert.pem' saved [252513/252513] $ curl --cacert /tmp/fullcacert.pem -v -u user:pass -T /path/to/source.xml https://serveur.domain/path/to/destination * About to connect() to serveur.domain port 443 (#0) * Trying 193.190.249.140... connected * Connected to serveur.domain (193.190.249.140) port 443 (#0) * successfully set certificate verify locations: * CAfile: /tmp/fullcacert.pem CApath: none * SSLv2, Client hello (1): * SSLv3, TLS handshake, Server hello (2): * SSLv3, TLS handshake, CERT (11): * SSLv3, TLS alert, Server hello (2): * SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed * Closing connection #0 curl: (60) SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed More details here: http://curl.haxx.se/docs/sslcerts.html curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). The default bundle is named curl-ca-bundle.crt; you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option.
Partager