This defines the function โgeminiโ such that you can visit a Gemini URL from the command line.
function gemini () { if [[ $1 =~ gemini://([^/:]+)(:([0-9]+))? ]]; then host=${BASH_REMATCH[1]} port=${BASH_REMATCH[3]:-1965} echo Contacting $host:$port... echo "$1" | openssl s_client -quiet -connect $host:$port 2>/dev/null else echo $1 is not a Gemini URL fi }
I should write another one that uses a client certificate, too. ๐
And hereโs an uploader using Titan.
function titan () { if [[ -z "$2" ]]; then echo Usage: $0 URL TOKEN [FILE] exit else token=$2 fi if [[ $1 =~ titan://([^/:]+)(:([0-9]+))? ]]; then host=${BASH_REMATCH[1]} port=${BASH_REMATCH[3]:-1965} echo Reading ${2:-/dev/stdin} read -d "" file < "${3:-/dev/stdin}" size=${#file} echo Posting $size bytes to $host:$port... printf "$1;token=$token;mime=text/plain;size=$size\r\n$file" \ | openssl s_client -quiet -connect $host:$port 2>/dev/null else echo $1 is not a Titan URL fi }
Hereโs how to call it:
echo "This is a Titan test." \ | titan titan://alexschroeder.ch/raw/Test hello
I put these two functions into a git repo.
โ#Bash โ#Gemini
(Please contact me if you want to remove your comment.)
โ
I guess the URL schema is superfluous. ๐
If somebody uses a client certificate with a common name set, we could use this to save a username when saving pages. An excellent way to self-identify.
Sadly, on the server side, I have not found a way to learn anything about the client certificate used. ๐
โ Alex Schroeder 2020-06-17 21:41 UTC
---
I depends upon the library you are using for TLS. I use libtls, which makes it not only easy to use TLS, but to obtain information from the client certificate.
โ Sean Conner 2020-06-17 22:21 UTC
---
Hm. I use Perlโs IO::Socket::SSL which allows me to examine the peer certificate, according to the do documentation but when I do it, there is nothing. ๐
โ Alex Schroeder 2020-06-18 12:42 UTC