1
# bash completion for openssl
8
# check if a specific configuration file is used
9
for (( i=2; i < COMP_CWORD; i++ )); do
10
if [[ "${COMP_WORDS[i]}" == -config ]]; then
11
config=${COMP_WORDS[i+1]}
16
# if no config given, check some usual default locations
17
if [ -z "$config" ]; then
18
for f in /etc/ssl/openssl.cnf /etc/pki/tls/openssl.cnf \
19
/usr/share/ssl/openssl.cnf; do
20
[ -f $f ] && config=$f && break
24
[ ! -f "$config" ] && return 0
26
COMPREPLY=( $( compgen -W "$( awk '/\[.*\]/ {print $2}' $config )" \
32
local cur prev commands command options formats
35
_get_comp_words_by_ref cur prev
37
commands='asn1parse ca ciphers crl crl2pkcs7 dgst dh dhparam dsa \
38
dsaparam ec ecparam enc engine errstr gendh gendsa genrsa \
39
nseq ocsp passwd pkcs12 pkcs7 pkcs8 prime rand req rsa \
40
rsautl s_client s_server s_time sess_id smime speed spkac \
41
verify version x509 md2 md4 md5 rmd160 sha sha1 aes-128-cbc \
42
aes-128-ecb aes-192-cbc aes-192-ecb aes-256-cbc aes-256-ecb \
43
base64 bf bf-cbc bf-cfb bf-ecb bf-ofb camellia-128-cbc \
44
camellia-128-ecb camellia-192-cbc camellia-192-ecb \
45
camellia-256-cbc camellia-256-ecb cast cast-cbc cast5-cbc \
46
cast5-cfb cast5-ecb cast5-ofb des des-cbc des-cfb des-ecb \
47
des-ede des-ede-cbc des-ede-cfb des-ede-ofb des-ede3 \
48
des-ede3-cbc des-ede3-cfb des-ede3-ofb des-ofb des3 desx rc2 \
49
rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc4 \
52
if [ $COMP_CWORD -eq 1 ]; then
53
COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) )
55
command=${COMP_WORDS[1]}
57
-CA|-CAfile|-CAkey|-CAserial|-cert|-certfile|-config|-content| \
58
-dcert|-dkey|-dhparam|-extfile|-in|-inkey|-kfile|-key|-keyout| \
59
-out|-oid|-prvrify|-rand|-recip|-revoke|-sess_in|-sess_out| \
60
-spkac|-sign|-signkey|-signer|-signature|-ss_cert|-untrusted| \
69
-name|-crlexts|-extensions)
73
-inform|-outform|-keyform|-certform|-CAform|-CAkeyform|-dkeyform|-dcertform)
77
formats="$formats NET"
80
formats="$formats SMIME"
83
COMPREPLY=( $( compgen -W "$formats" -- "$cur" ) )
87
_known_hosts_real "$cur"
91
COMPREPLY=( $( compgen -W 'smtp pop3 imap ftp' \
96
COMPREPLY=( $( compgen -W "$(openssl ciphers | \
97
tr ':' '\n')" -- "$cur" ) )
102
if [[ "$cur" == -* ]]; then
103
# possible options for the command
106
options='-inform -in -out -noout -offset -length -i -oid \
110
options='-verbose -config -name -gencrl -revoke \
111
-crl_reason -crl_hold -crl_compromise \
112
-crl_CA_compromise -crldays -crlhours -crlexts \
113
-startdate -enddate -days -md -policy -keyfile -key \
114
-passin -cert -selfsig -in -out -notext -outdir \
115
-infiles -spkac -ss_cert -preserveDN -noemailDN \
116
-batch -msie_hack -extensions -extfile -engine \
117
-subj -utf8 -multivalue-rdn'
120
options='-v -ssl2 -ssl3 -tls1'
123
options='-inform -outform -text -in -out -noout -hash \
124
-issuer -lastupdate -nextupdate -CAfile -CApath'
127
options='-inform -outform -in -out -print_certs'
130
options='-md5 -md4 -md2 -sha1 -sha -mdc2 -ripemd160 -dss1 \
131
-c -d -hex -binary -out -sign -verify -prverify \
135
options='-inform -outform -in -passin -out -passout -des \
136
-des3 -idea -text -noout -modulus -pubin -pubout'
139
options='-inform -outform -in -out -noout -text -C -rand \
143
options='-ciphername -in -out -pass -e -d -a -A -k -kfile \
144
-S -K -iv -p -P -bufsize -debug'
147
options='-inform -outform -in -out -dsaparam -noout -text \
151
options='-out -des -des3 -idea -rand'
154
options='-out -passout -des -des3 -idea -f4 -3 -rand'
157
options='-inform -outform -in -out -print_certs -text \
161
options='-out -rand -base64'
164
options='-inform -outform -in -passin -out -passout -text \
165
-noout -verify -modulus -new -rand -newkey -newkey \
166
-nodes -key -keyform -keyout -md5 -sha1 -md2 -mdc2 \
167
-config -x509 -days -asn1-kludge -newhdr -extensions \
171
options='-inform -outform -in -passin -out -passout \
172
-sgckey -des -des3 -idea -text -noout -modulus -check \
173
-pubin -pubout -engine'
176
options='-in -out -inkey -pubin -certin -sign -verify \
177
-encrypt -decrypt -pkcs -ssl -raw -hexdump -asn1parse'
180
options='-connect -verify -cert -certform -key -keyform \
181
-pass -CApath -CAfile -reconnect -pause -showcerts \
182
-debug -msg -nbio_test -state -nbio -crlf -ign_eof \
183
-quiet -ssl2 -ssl3 -tls1 -no_ssl2 -no_ssl3 -no_tls1 \
184
-bugs -cipher -starttls -engine -tlsextdebug \
185
-no_ticket -sess_out -sess_in -rand'
188
options='-accept -context -verify -Verify -crl_check \
189
-crl_check_all -cert -certform -key -keyform -pass \
190
-dcert -dcertform -dkey -dkeyform -dpass -dhparam \
191
-nbio -nbio_test -crlf -debug -msg -state -CApath \
192
-CAfile -nocert -cipher -quiet -no_tmp_rsa -ssl2 \
193
-ssl3 -tls1 -no_ssl2 -no_ssl3 -no_tls1 -no_dhe \
194
-bugs -hack -www -WWW -HTTP -engine -tlsextdebug \
195
-no_ticket -id_prefix -rand'
198
options='-connect -www -cert -key -CApath -CAfile -reuse \
199
-new -verify -nbio -time -ssl2 -ssl3 -bugs -cipher'
202
options='-inform -outform -in -out -text -noout -context \
206
options='-encrypt -decrypt -sign -verify -pk7out -des \
207
-des3 -rc2-40 -rc2-64 -rc2-128 -aes128 -aes192 -aes256 \
208
-in -certfile -signer -recip -inform -passin -inkey \
209
-out -outform -content -to -from -subject -text -rand'
215
options='-CApath -CAfile -purpose -untrusted -help \
216
-issuer_checks -verbose -certificates'
219
options='-inform -outform -keyform -CAform -CAkeyform -in \
220
-out -serial -hash -subject_hash -issuer_hash -subject \
221
-issuer -nameopt -email -startdate -enddate -purpose \
222
-dates -modulus -fingerprint -alias -noout -trustout \
223
-clrtrust -clrreject -addtrust -addreject -setalias \
224
-days -set_serial -signkey -x509toreq -req -CA -CAkey \
225
-CAcreateserial -CAserial -text -C -md2 -md5 -sha1 \
226
-mdc2 -clrext -extfile -extensions -engine'
228
md5|md4|md2|sha1|sha|mdc2|ripemd160)
232
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
234
if [[ "$command" == speed ]]; then
235
COMPREPLY=( $( compgen -W 'md2 mdc2 md5 hmac sha1 rmd160 \
236
idea-cbc rc2-cbc rc5-cbc bf-cbc des-cbc des-ede3 rc4 \
237
rsa512 rsa1024 rsa2048 rsa4096 dsa512 dsa1024 dsa2048 idea \
238
rc2 des rsa blowfish' -- "$cur" ) )
245
complete -F _openssl -o default openssl
251
# sh-indent-comment: t
252
# indent-tabs-mode: nil
254
# ex: ts=4 sw=4 et filetype=sh