Connect to HTTPS Servers Using Racket

When I try to connect to the web server via HTTPS using the Racket package net/http-client, the following will happen:

WITH #t

➜  code  racket                
Welcome to Racket v6.2.
> (require net/http-client)
> (http-sendrecv "google.com" "/" #:ssl? #t)
ssl-connect: requested protocol not supported
  requested: 'auto
  context...:
   /usr/local/share/racket/collects/openssl/mzssl.rkt:608:0: make-raw-context
   /usr/local/share/racket/collects/openssl/mzssl.rkt:482:18
   /usr/local/share/racket/collects/racket/private/more-scheme.rkt:264:2: call-with-exception-handler
   /usr/local/share/racket/collects/net/http-client.rkt:294:0: http-sendrecv92
   /usr/local/share/racket/collects/racket/private/misc.rkt:87:7

WITH 'tls

> (require net/http-client)
> (http-sendrecv "google.com" "/" #:ssl? 'tls)
ssl-connect: requested protocol not supported
  requested: 'tls
  context...:
   /usr/local/share/racket/collects/openssl/mzssl.rkt:608:0: make-raw-context
   /usr/local/share/racket/collects/openssl/mzssl.rkt:482:18
   /usr/local/share/racket/collects/racket/private/more-scheme.rkt:264:2: call-with-exception-handler
   /usr/local/share/racket/collects/net/http-client.rkt:294:0: http-sendrecv92
   /usr/local/share/racket/collects/racket/private/misc.rkt:87:7

Conclusion (supported-client-protocols)

> (require openssl)
> (supported-client-protocols)
'()

How to use http-sendrecvHTTPS to connect to the server?

+4
source share
2 answers

If you use Linux, this may happen because Racket is not aware of the version of the OpenSSL library that you installed. Confirm by checking ssl-load-fail-reasonas @soegaard suggested.

The workaround is to install the OpenSSL development kit ( libssl-devor openssl-develsomething like that), which includes a symlink to the shared library without support.

+3
source

'tls #t.

> (require net/http-client)
> (http-sendrecv "google.com" "/" #:ssl? 'tls)
#"HTTP/1.1 302 Found"
'(#"Location: https://www.google.dk/?gws_rd=cr&ei=10q1Ve3dMsm4sQGd_KioAQ"
  #"Cache-Control: private"
  #"Content-Type: text/html; charset=UTF-8"
  #"P3P: CP=\"This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info.\""
  #"Date: Sun, 26 Jul 2015 21:02:15 GMT"
  #"Server: gws"
  #"Content-Length: 259"
  #"X-XSS-Protection: 1; mode=block"
  #"X-Frame-Options: SAMEORIGIN"
  #"Set-Cookie: PREF=ID=1111111111111111:FF=0:TM=1437944535:LM=1437944535:V=1:S=_FmpeZRsEpdAXW_-; expires=Tue, 25-Jul-2017 21:02:15 GMT; path=/; domain=.google.com"
  #"Set-Cookie: NID=69=GDETUcLzNFvaXS9uD9fxW_rA-k3ywu9vsb8VVCBUUOrbL-BmWjxpj0duYXoNZyH0EHMt54dmVnn3xPJvESfM4tLy_T8DYCsas_9dloNB9s6NfcxmbeD4DQzAAou0ly_l; expires=Mon, 25-Jan-2016 21:02:15 GMT; path=/; domain=.google.com; HttpOnly"
  #"Connection: close")
#<input-port:pipe>
+3

Source: https://habr.com/ru/post/1599761/


All Articles