From ba52df92e9d9558cc04c1b5f9b10ee06fef278bc Mon Sep 17 00:00:00 2001 From: Fuan200 Date: Mon, 16 Jun 2025 08:52:28 -0600 Subject: [PATCH] add expired certificate detection & add it.po on script translate --- src/en.po | 30 ++++++++++++++-------- src/es.po | 30 ++++++++++++++-------- src/fr.po | 33 ++++++++++++++++-------- src/it.po | 33 ++++++++++++++++-------- src/rebuild-translatable-strings.sh | 1 + src/sslcheck.c | 32 +++++++++++++++++++---- src/sslcheck.pot | 40 ++++++++++++++++++----------- 7 files changed, 137 insertions(+), 62 deletions(-) mode change 100644 => 100755 src/rebuild-translatable-strings.sh diff --git a/src/en.po b/src/en.po index 574b81c..2a4a4f3 100644 --- a/src/en.po +++ b/src/en.po @@ -2,12 +2,11 @@ # Copyright (C) 2025 Alexia Michelle # This file is distributed under the same license as the sslcheck package. # Alexia Michelle , 2025. - msgid "" msgstr "" "Project-Id-Version: sslcheck 1.2.0\n" -"Report-Msgid-Bugs-To: alexia@goldendoglinux.org\n" -"POT-Creation-Date: 2025-06-15 21:03-0300\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-06-16 08:36-0600\n" "PO-Revision-Date: 2025-06-15 21:10-0300\n" "Last-Translator: Alexia Michelle \n" "Language-Team: English \n" @@ -27,7 +26,8 @@ msgid "" "sslcheck prints domain and remainder of days until cert " "expires\n" msgstr "" -"sslcheck prints domain and remainder of days until cert expires\n" +"sslcheck prints domain and remainder of days until cert " +"expires\n" #: sslcheck.c:67 #, c-format @@ -54,32 +54,42 @@ msgstr "-h --help prints this menu\n" msgid "-v --version prints version\n" msgstr "-v --version prints version\n" -#: sslcheck.c:138 +#: sslcheck.c:152 #, c-format msgid "Error creating SSL context\n" msgstr "Error creating SSL context\n" -#: sslcheck.c:153 +#: sslcheck.c:167 #, c-format msgid "Error getting SSL object\n" msgstr "Error getting SSL object\n" -#: sslcheck.c:166 +#: sslcheck.c:180 #, c-format msgid "Error connecting to %s\n" msgstr "Error connecting to %s\n" -#: sslcheck.c:177 +#: sslcheck.c:191 #, c-format msgid "No certificate found for %s\n" msgstr "No certificate found for %s\n" -#: sslcheck.c:188 +#: sslcheck.c:204 #, c-format msgid "Could not calculate certificate expiration\n" msgstr "Could not calculate certificate expiration\n" -#: sslcheck.c:195 +#: sslcheck.c:214 +#, c-format +msgid "Expired %d days ago\n" +msgstr "Expired %d days ago\n" + +#: sslcheck.c:220 +#, c-format +msgid "Domain: %s | Certificate EXPIRED %d days ago\n" +msgstr "Domain: %s | Certificate EXPIRED %d days ago\n" + +#: sslcheck.c:222 #, c-format msgid "Domain: %s | Days until Certification expires: %d\n" msgstr "Domain: %s | Days until Certification expires: %d\n" diff --git a/src/es.po b/src/es.po index 31fb98b..e8385b7 100644 --- a/src/es.po +++ b/src/es.po @@ -2,12 +2,11 @@ # Copyright (C) 2025 Alexia Michelle # This file is distributed under the same license as the sslcheck package. # Alexia Michelle , 2025. - msgid "" msgstr "" "Project-Id-Version: sslcheck 1.2.0\n" -"Report-Msgid-Bugs-To: alexia@goldendoglinux.org\n" -"POT-Creation-Date: 2025-06-15 21:03-0300\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-06-16 08:36-0600\n" "PO-Revision-Date: 2025-06-15 21:10-0300\n" "Last-Translator: Alexia Michelle \n" "Language-Team: Spanish \n" @@ -27,7 +26,8 @@ msgid "" "sslcheck prints domain and remainder of days until cert " "expires\n" msgstr "" -"sslcheck muestra el dominio y los días restantes hasta que expire el certificado\n" +"sslcheck muestra el dominio y los días restantes hasta que " +"expire el certificado\n" #: sslcheck.c:67 #, c-format @@ -54,32 +54,42 @@ msgstr "-h --help muestra este menú\n" msgid "-v --version prints version\n" msgstr "-v --version muestra la versión\n" -#: sslcheck.c:138 +#: sslcheck.c:152 #, c-format msgid "Error creating SSL context\n" msgstr "Error creando el contexto SSL\n" -#: sslcheck.c:153 +#: sslcheck.c:167 #, c-format msgid "Error getting SSL object\n" msgstr "Error obteniendo el objeto SSL\n" -#: sslcheck.c:166 +#: sslcheck.c:180 #, c-format msgid "Error connecting to %s\n" msgstr "Error al conectar a %s\n" -#: sslcheck.c:177 +#: sslcheck.c:191 #, c-format msgid "No certificate found for %s\n" msgstr "No se encontró certificado para %s\n" -#: sslcheck.c:188 +#: sslcheck.c:204 #, c-format msgid "Could not calculate certificate expiration\n" msgstr "No se pudo calcular la expiración del certificado\n" -#: sslcheck.c:195 +#: sslcheck.c:214 +#, c-format +msgid "Expired %d days ago\n" +msgstr "Caducado hace %d días\n" + +#: sslcheck.c:220 +#, c-format +msgid "Domain: %s | Certificate EXPIRED %d days ago\n" +msgstr "Dominio: %s | Certificado caducado hace %d días\n" + +#: sslcheck.c:222 #, c-format msgid "Domain: %s | Days until Certification expires: %d\n" msgstr "Dominio: %s | Días hasta que vence el certificado: %d\n" diff --git a/src/fr.po b/src/fr.po index 6ea0a66..974673c 100644 --- a/src/fr.po +++ b/src/fr.po @@ -2,12 +2,11 @@ # Copyright (C) 2025 Alexia Michelle # This file is distributed under the same license as the sslcheck package. # Alexia Michelle , 2025. - msgid "" msgstr "" "Project-Id-Version: sslcheck 1.2.0\n" -"Report-Msgid-Bugs-To: alexia@goldendoglinux.org\n" -"POT-Creation-Date: 2025-06-15 21:03-0300\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-06-16 08:36-0600\n" "PO-Revision-Date: 2025-06-15 21:10-0300\n" "Last-Translator: Alexia Michelle \n" "Language-Team: French \n" @@ -27,7 +26,8 @@ msgid "" "sslcheck prints domain and remainder of days until cert " "expires\n" msgstr "" -"sslcheck affiche le domaine et le nombre de jours restants avant l'expiration du certificat\n" +"sslcheck affiche le domaine et le nombre de jours restants " +"avant l'expiration du certificat\n" #: sslcheck.c:67 #, c-format @@ -42,7 +42,8 @@ msgstr "-j --json affiche la sortie au format JSON\n" #: sslcheck.c:69 #, c-format msgid "-p --port use custom port instead of 443\n" -msgstr "-p --port utilise un port personnalisé à la place de 443\n" +msgstr "" +"-p --port utilise un port personnalisé à la place de 443\n" #: sslcheck.c:70 #, c-format @@ -54,32 +55,42 @@ msgstr "-h --help affiche ce menu\n" msgid "-v --version prints version\n" msgstr "-v --version affiche la version\n" -#: sslcheck.c:138 +#: sslcheck.c:152 #, c-format msgid "Error creating SSL context\n" msgstr "Erreur lors de la création du contexte SSL\n" -#: sslcheck.c:153 +#: sslcheck.c:167 #, c-format msgid "Error getting SSL object\n" msgstr "Erreur lors de l'obtention de l'objet SSL\n" -#: sslcheck.c:166 +#: sslcheck.c:180 #, c-format msgid "Error connecting to %s\n" msgstr "Erreur de connexion à %s\n" -#: sslcheck.c:177 +#: sslcheck.c:191 #, c-format msgid "No certificate found for %s\n" msgstr "Aucun certificat trouvé pour %s\n" -#: sslcheck.c:188 +#: sslcheck.c:204 #, c-format msgid "Could not calculate certificate expiration\n" msgstr "Impossible de calculer l'expiration du certificat\n" -#: sslcheck.c:195 +#: sslcheck.c:214 +#, c-format +msgid "Expired %d days ago\n" +msgstr "Expiré il y a %d jours\n" + +#: sslcheck.c:220 +#, c-format +msgid "Domain: %s | Certificate EXPIRED %d days ago\n" +msgstr "Domaine : %s | Certificat expiré il y a %d jours\n" + +#: sslcheck.c:222 #, c-format msgid "Domain: %s | Days until Certification expires: %d\n" msgstr "Domaine: %s | Jours restants avant expiration du certificat: %d\n" diff --git a/src/it.po b/src/it.po index 4ae093e..76a118f 100644 --- a/src/it.po +++ b/src/it.po @@ -2,12 +2,11 @@ # Copyright (C) 2025 Alexia Michelle # This file is distributed under the same license as the sslcheck package. # Alexia Michelle , 2025. - msgid "" msgstr "" "Project-Id-Version: sslcheck 1.2.0\n" -"Report-Msgid-Bugs-To: alexia@goldendoglinux.org\n" -"POT-Creation-Date: 2025-06-15 21:03-0300\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-06-16 08:36-0600\n" "PO-Revision-Date: 2025-06-15 21:10-0300\n" "Last-Translator: Alexia Michelle \n" "Language-Team: Italian \n" @@ -27,7 +26,8 @@ msgid "" "sslcheck prints domain and remainder of days until cert " "expires\n" msgstr "" -"sslcheck mostra il dominio e i giorni rimanenti fino alla scadenza del certificato\n" +"sslcheck mostra il dominio e i giorni rimanenti fino alla " +"scadenza del certificato\n" #: sslcheck.c:67 #, c-format @@ -42,7 +42,8 @@ msgstr "-j --json mostra l'output in formato JSON\n" #: sslcheck.c:69 #, c-format msgid "-p --port use custom port instead of 443\n" -msgstr "-p --port usa una porta personalizzata invece di 443\n" +msgstr "" +"-p --port usa una porta personalizzata invece di 443\n" #: sslcheck.c:70 #, c-format @@ -54,32 +55,42 @@ msgstr "-h --help mostra questo menu\n" msgid "-v --version prints version\n" msgstr "-v --version mostra la versione\n" -#: sslcheck.c:138 +#: sslcheck.c:152 #, c-format msgid "Error creating SSL context\n" msgstr "Errore nella creazione del contesto SSL\n" -#: sslcheck.c:153 +#: sslcheck.c:167 #, c-format msgid "Error getting SSL object\n" msgstr "Errore nell'ottenimento dell'oggetto SSL\n" -#: sslcheck.c:166 +#: sslcheck.c:180 #, c-format msgid "Error connecting to %s\n" msgstr "Errore di connessione a %s\n" -#: sslcheck.c:177 +#: sslcheck.c:191 #, c-format msgid "No certificate found for %s\n" msgstr "Nessun certificato trovato per %s\n" -#: sslcheck.c:188 +#: sslcheck.c:204 #, c-format msgid "Could not calculate certificate expiration\n" msgstr "Impossibile calcolare la scadenza del certificato\n" -#: sslcheck.c:195 +#: sslcheck.c:214 +#, c-format +msgid "Expired %d days ago\n" +msgstr "Scaduto %d giorni fa\n" + +#: sslcheck.c:220 +#, c-format +msgid "Domain: %s | Certificate EXPIRED %d days ago\n" +msgstr "Dominio: %s | Certificato SCADUTO %d giorni fa\n" + +#: sslcheck.c:222 #, c-format msgid "Domain: %s | Days until Certification expires: %d\n" msgstr "Dominio: %s | Giorni fino alla scadenza del certificato: %d\n" diff --git a/src/rebuild-translatable-strings.sh b/src/rebuild-translatable-strings.sh old mode 100644 new mode 100755 index d85431a..eab350f --- a/src/rebuild-translatable-strings.sh +++ b/src/rebuild-translatable-strings.sh @@ -8,4 +8,5 @@ xgettext -k_ -o sslcheck.pot sslcheck.c msgmerge --update es.po sslcheck.pot msgmerge --update fr.po sslcheck.pot msgmerge --update en.po sslcheck.pot +msgmerge --update it.po sslcheck.pot echo "strings updated. Review the lines that require translation" diff --git a/src/sslcheck.c b/src/sslcheck.c index 5fdd973..a14c25b 100644 --- a/src/sslcheck.c +++ b/src/sslcheck.c @@ -72,13 +72,21 @@ void print_help() { } // Calcula días hasta expiración -int days_until_expiration(X509 *cert) { +int days_until_expiration(X509 *cert, int *is_expired) { const ASN1_TIME *notAfter = X509_get0_notAfter(cert); ASN1_TIME *asn1_now = ASN1_TIME_new(); ASN1_TIME_set(asn1_now, time(NULL)); int days = 0, seconds = 0; ASN1_TIME_diff(&days, &seconds, asn1_now, notAfter); + + if (days < 0) { + *is_expired = 1; + days = -days; + } else { + *is_expired = 0; + } + ASN1_TIME_free(asn1_now); return days; } @@ -186,7 +194,9 @@ int main(int argc, char **argv) { return EXIT_FAILURE; } - int days = days_until_expiration(cert); + int is_expired = 0; + int days = days_until_expiration(cert, &is_expired); + if (days < 0) { if (json_output) printf("{\"domain\": \"%s\", \"days\": null}\n", hostname); @@ -194,11 +204,23 @@ int main(int argc, char **argv) { fprintf(stderr, _("Could not calculate certificate expiration\n")); } else { if (json_output) { - printf("{\"domain\": \"%s\", \"days\": %d}\n", hostname, days); + if (is_expired) { + printf("{\"domain\": \"%s\", \"days\": %d, \"status\": \"expired\"}\n", hostname, days); + } else { + printf("{\"domain\": \"%s\", \"days\": %d, \"status\": \"valid\"}\n", hostname, days); + } } else if (short_output) { - printf("%d\n", days); + if (is_expired) { + printf(_("Expired %d days ago\n"), days); + } else { + printf("%d\n", days); + } } else { - printf(_("Domain: %s | Days until Certification expires: %d\n"), hostname, days); + if (is_expired) { + printf(_("Domain: %s | Certificate EXPIRED %d days ago\n"), hostname, days); + } else { + printf(_("Domain: %s | Days until Certification expires: %d\n"), hostname, days); + } } } diff --git a/src/sslcheck.pot b/src/sslcheck.pot index 0eca454..976250d 100644 --- a/src/sslcheck.pot +++ b/src/sslcheck.pot @@ -1,20 +1,20 @@ -# Translations template for sslcheck. -# Copyright (C) 2025 Alexia Michelle -# This file is distributed under the same license as the sslcheck package. -# Alexia Michelle , 2025. +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. # - +#, fuzzy msgid "" msgstr "" -"Project-Id-Version: sslcheck 1.2.0\n" -"Report-Msgid-Bugs-To: alexia@goldendoglinux.org\n" -"POT-Creation-Date: 2025-06-15 21:03-0300\n" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-06-16 08:36-0600\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" +"Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #: sslcheck.c:58 sslcheck.c:64 @@ -54,32 +54,42 @@ msgstr "" msgid "-v --version prints version\n" msgstr "" -#: sslcheck.c:138 +#: sslcheck.c:152 #, c-format msgid "Error creating SSL context\n" msgstr "" -#: sslcheck.c:153 +#: sslcheck.c:167 #, c-format msgid "Error getting SSL object\n" msgstr "" -#: sslcheck.c:166 +#: sslcheck.c:180 #, c-format msgid "Error connecting to %s\n" msgstr "" -#: sslcheck.c:177 +#: sslcheck.c:191 #, c-format msgid "No certificate found for %s\n" msgstr "" -#: sslcheck.c:188 +#: sslcheck.c:204 #, c-format msgid "Could not calculate certificate expiration\n" msgstr "" -#: sslcheck.c:195 +#: sslcheck.c:214 +#, c-format +msgid "Expired %d days ago\n" +msgstr "" + +#: sslcheck.c:220 +#, c-format +msgid "Domain: %s | Certificate EXPIRED %d days ago\n" +msgstr "" + +#: sslcheck.c:222 #, c-format msgid "Domain: %s | Days until Certification expires: %d\n" msgstr ""