http-client: Add #:verify-certificate? to 'http-fetch'.
* guix/http-client.scm (http-fetch): Add #:verify-certificate? parameter and pass it to 'open-connection-for-uri'.
This commit is contained in:
		
							parent
							
								
									eda2ad5cd1
								
							
						
					
					
						commit
						17cff9c662
					
				
					 1 changed files with 6 additions and 2 deletions
				
			
		|  | @ -223,7 +223,7 @@ or if EOF is reached." | ||||||
|                 'shutdown (const #f)) |                 'shutdown (const #f)) | ||||||
| 
 | 
 | ||||||
| (define* (http-fetch uri #:key port (text? #f) (buffered? #t) | (define* (http-fetch uri #:key port (text? #f) (buffered? #t) | ||||||
|                      keep-alive?) |                      keep-alive? (verify-certificate? #t)) | ||||||
|   "Return an input port containing the data at URI, and the expected number of |   "Return an input port containing the data at URI, and the expected number of | ||||||
| bytes available or #f.  If TEXT? is true, the data at URI is considered to be | bytes available or #f.  If TEXT? is true, the data at URI is considered to be | ||||||
| textual.  Follow any HTTP redirection.  When BUFFERED? is #f, return an | textual.  Follow any HTTP redirection.  When BUFFERED? is #f, return an | ||||||
|  | @ -231,11 +231,15 @@ unbuffered port, suitable for use in `filtered-port'.  When KEEP-ALIVE? is | ||||||
| true, send a 'Connection: keep-alive' HTTP header, in which case PORT may be | true, send a 'Connection: keep-alive' HTTP header, in which case PORT may be | ||||||
| reused for future HTTP requests. | reused for future HTTP requests. | ||||||
| 
 | 
 | ||||||
|  | When VERIFY-CERTIFICATE? is true, verify HTTPS server certificates. | ||||||
|  | 
 | ||||||
| Raise an '&http-get-error' condition if downloading fails." | Raise an '&http-get-error' condition if downloading fails." | ||||||
|   (let loop ((uri (if (string? uri) |   (let loop ((uri (if (string? uri) | ||||||
|                       (string->uri uri) |                       (string->uri uri) | ||||||
|                       uri))) |                       uri))) | ||||||
|     (let ((port (or port (open-connection-for-uri uri))) |     (let ((port (or port (open-connection-for-uri uri | ||||||
|  |                                                   #:verify-certificate? | ||||||
|  |                                                   verify-certificate?))) | ||||||
|           (auth-header (match (uri-userinfo uri) |           (auth-header (match (uri-userinfo uri) | ||||||
|                          ((? string? str) |                          ((? string? str) | ||||||
|                           (list (cons 'Authorization |                           (list (cons 'Authorization | ||||||
|  |  | ||||||
		Reference in a new issue