From bc63090e7be7b14b7c35f66cd39b57db77fd941b Mon Sep 17 00:00:00 2001
From: Gabriel Moreau <gabriel.moreau@univ-grenoble-alpes.fr>
Date: Thu, 3 Aug 2023 16:04:29 +0200
Subject: [PATCH] Better completion and simple test before some text openssl
 command

---
 bash_completion | 3 ++-
 certcheck       | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/bash_completion b/bash_completion
index f4139ab..77fb678 100644
--- a/bash_completion
+++ b/bash_completion
@@ -11,7 +11,8 @@ _certcheck() {
 
    if [[ $COMP_CWORD -gt 1 && "${COMP_WORDS[1]}" =~ 'check'|'text'|'txt' ]]
    then
-      COMPREPLY=($(compgen -f -- "$cur"|grep -v -f <(compgen  -d --|sed -e 's/^/^/;s/$/\$/;'); compgen -d -S / -- "$cur"))
+      #COMPREPLY=($(compgen -f -o default -X '!*.@(pem|crt)' -- "$cur"|grep -v -f <(compgen  -d -- "$cur"|sed -e 's/^/^/;s/$/\$/;'); compgen -S "/" -d -- "${cur}")) ; compopt -o nospace;
+      compopt -o default; COMPREPLY=()
    elif [[ $COMP_CWORD -eq 1 ]]
    then
       COMPREPLY=($(compgen -W "$(/usr/bin/certcheck help | grep '^ certcheck' | awk '{print $2}' | xargs echo -n)" -- "$cur"))
diff --git a/certcheck b/certcheck
index 9462fef..275e49c 100755
--- a/certcheck
+++ b/certcheck
@@ -5,7 +5,7 @@
 export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
 export LANG=C
 
-export VERSION=0.3.4
+export VERSION=0.3.5
 
 function usage() {
    cat <<END_USAGE
@@ -107,6 +107,8 @@ case "${action}" in
 
    text|txt)
       [ -s "${CRT}" ] || say_warning "missing ${CRT}"
+      grep -q -- '-----BEGIN PRIVATE KEY-----' && say_warning "give the public and not the private key!"
+      grep -q -- '-----BEGIN CERTIFICATE-----' || say_warning "your key is not in PEM format!"
       openssl x509 -noout -text -in "${CRT}" \
          | egrep '(Subject|Not Before|Not After[[:space:]]|DNS|Issuer):' \
          | sed -e 's/^\s*//g;' \
-- 
GitLab