Outils pour utilisateurs

Outils du site


blog

openssl - vérifier la cohérence d'un certificat entre KEY CSR CRT

openssl pkey -in privateKey.key -pubout -outform pem | sha256sum
openssl x509 -in certificate.crt -pubkey -noout -outform pem | sha256sum
openssl req -in CSR.csr -pubkey -noout -outform pem | sha256sum

Source https://www.sslshopper.com/certificate-key-matcher.html

2025/03/24 15:06

OpenSSL - Quels sont les SANs (Subject Alternative Names) de mon certificat SSL/TLS

Fichier certificat

openssl x509 -text -noout -fingerprint -sha256 -in plop.cer | grep DNS

En ligne

openssl s_client -connect plop.acme.org:443 -servername plop.acme.org </dev/null | openssl x509 -text -noout -in - | grep DNS | sed -e 's/ DNS:/\n&/g'

Test

$ curl -v https://test.acme.fr 2>&1 | grep subject
*  subject: C=FR; O=ACME FRANCE; OU=Private Group PKI; CN=www.test.acme.fr
*  subjectAltName does not match test.acme.fr
* SSL: no alternative certificate subject name matches target host name 'test.acme.fr'
curl: (51) SSL: no alternative certificate subject name matches target host name 'test.acme.fr'

Ou encore mieux :

$  echo | openssl s_client -connect redhat.com:443 2>/dev/null | openssl x509 -noout -ext subjectAltName
X509v3 Subject Alternative Name:
    DNS:*.redhat.com, DNS:redhat.com
2025/03/24 15:06

OpenSSL - Est-ce bien le bon certificat SSL/TLS qui est installé sur le serveur Web

openssl x509 -text -noout -fingerprint -sha256 -in plop.cer | grep Fingerprint
 
openssl s_client -connect plop.acme.org:443 -servername plop.acme.org </dev/null | openssl x509 -text -noout -fingerprint -sha256 -in - | grep Fingerprint
2025/03/24 15:06

Notes OpenBSD

Installation de paquets (Git, vim...)
export PKG_PATH=ftp://ftp.fr.openbsd.org/pub/OpenBSD/5.6/packages/amd64/

Mise à jour

pkg_add -Uu
2025/03/24 15:06

NTP temps horloge heure

Lexiques

Strate : Strate de la source. La strate 1 indique une source avec une horloge de référence attachée localement. Une source synchronisée avec une source Stratum 1 est définie sur Stratum 2. Une source synchronisée avec une source de strate 2 est définie sur Stratum 3, et ainsi de suite. Source : https://docs.aws.amazon.com/fr_fr/snowball/latest/developer-guide/setting-ntp.html

Type : Les sources NTP (Network Time Protocol) peuvent être un serveur (server) ou un pair (peer), c'est à dire client.

Configurer

Configurer via SystemD

/etc/systemd/timesyncd.conf

[Time]
Servers=0.debian.pool.ntp.org 1.debian.pool.ntp.org
timedatectl set-ntp true

Diag

systemctl restart systemd-timesyncd
systemctl status systemd-timesyncd
Configurer via Chrony

TODO

Configurer via NTP
aptitude install ntp

On configure le serveur de temps via le fichier

Notamment les lignes suivantes:

/etc/ntp.conf

# le serveur doit lui aussi se synchroniser

server 0.fr.pool.ntp.org # ou debian.pool.ntp.org
server 1.fr.pool.ntp.org # ou debian.pool.ntp.org
server 2.fr.pool.ntp.org # ou debian.pool.ntp.org
server 3.fr.pool.ntp.org # ou debian.pool.ntp.org

# Autoriser les autres ordinateurs à ce connecter:

restrict 0.0.0.0 mask 0.0.0.0

# Limiter les ordinateurs pouvant se connecter à notre réseau personnel:

broadcast 192.168.0.255
The systems were using only two NTP servers

Four NTP servers are recommended. See http://support.ntp.org/bin/view/Support/SelectingOffsiteNTPServers

“With two, it is impossible to tell which one is better, because you don't have any other references to compare them with. This is actually the worst possible configuration -- you'd be better off using just one upstream time server and letting the clocks run free if that upstream were to die or become unreachable.”

“Use at least 4 NTP servers”

Pour éviter la dérive sur les VM

Ou passer à Chrony

tinker panic 0

“The tinker panic value of 0 tells NTP that no matter what the time offset is, not to panic and exit. This is recommended for virtual machines because virtual machines have no physical clock and can be paused at anytime and started back up hours later.”

Source : https://www.redhat.com/en/blog/avoiding-clock-drift-vms

Voir :

1 - Add the following line to the beginning of the /etc/ntp.conf file

tinker panic 0

2 - Remove or comment the “driftfile”

#driftfile /var/lib/ntp/drift/ntp.drift # path for drift file

3 - Restart the ntpd.service

/bin/systemctl restart ntpd.service

Voir https://www.suse.com/fr-fr/support/kb/doc/?id=000021102

Configurer via ntpdate

ntpdate -B ajustement progressif

ntpdate -b ajustement brutal

aptitude install ntpdate

Utilisation manuel

/usr/sbin/ntpdate -dvu 192.168.2.11

Automatisation

crontab -e

Ajouter la ligne suivante:

0 3 * * * root /usr/sbin/ntpdate -dv ntp.serveur.org > /dev/null

Tester / simuler / lecture seul / dry-run

ntpdate -q pool.ntp.org
Autres

/etc/sysconfig/ntp

SYNC_HWCLOCK=yes

This is an option to ntpdate

Horloge matérielle / BIOS / hwclock

Afficher la date et l’heure

date

Si la date est incorrecte, utiliser date MMDDmm

Afficher l’heure du BIOS

hwclock

Commande pour que le BIOS puisse utiliser l’heure du système

hwclock --systohc --utc

Comparaison du temps système et le BIOS

date
hwclock

Vérification dans le fichier /etc/sysconfig/clock

UTC=true

Vérifier

Source: https://www.cyberciti.biz/faq/linux-unix-bsd-is-ntp-client-working/

Commandes pour vérifier

  • ntpq – standard NTP query program
  • ntpstat – show network time synchronisation status
  • timedatectl – show or set info about ntp using systemd
  • chronyc tracking
ntpstat
ntpstat
Exit status Error
0 Clock is synchronised.
1 Clock is not synchronised.
2 If clock state is indeterminant, for example if ntpd is not contactable
ntpq
ntpq -pn

Source : https://www.system-linux.eu/index.php?post/2010/01/05/Mettre-vos-serveurs-%C3%A0-la-bonne-heure-avec-NTP

# ntpq -p

remote           refid      st t when poll reach   delay   offset  jitter
===========================================
europium.canoni 193.79.237.14  2 u  15  64  1  28.682 -3.649 0.015
horlogegps.rese 10.3.128.189   2 u  14  64  1  29.002 -11.238 0.015
kontir.mkc.fr   213.251.128.249  2 u  13  64  1  76.501 18.866 0.015
dnscache-london 140.203.16.5   2 u  12  64  1  58.209  4.266 0.015

Une fois la synchronisation faite des , + et - apparaissent devant les noms de serveur. Le serveur précédé d’une astérisque () est celui utilisé, ceux précédés d’un moins (-) sont actuellement éliminés par l’algorithme de choix des serveurs, ceux précédés d’un plus (+) sont des candidats potentiels à la synchronisation et ceux précédés d’un espace sont soit inaccessibles, soit trop éloignés.

Une synchronisation correcte implique une valeur de « delay » et de « offset » non nulle, et de « jitter » inférieure à 100

Resynchroniser

sudo service ntp stop
sudo ntpd -gq
sudo service ntp start
SystemD - timedatectl
timedatectl status | grep NTP
     NTP enabled: yes
NTP synchronized: yes
timedatectl set-timezone "Europe/Paris"
timedatectl set-time "2026-07-29 10:11:48"
Chrony - chronyc
chronyc tracking
chronyc sources
chronyc sourcestats

Autres

Timesyncd

/lib/systemd/system/systemd-timesyncd.service.d/wsl.conf

# Enable timesyncd on WSL machines
# so WSL clock is synced on resume from suspend of the host.
 
[Unit]
ConditionVirtualization=
ConditionVirtualization=|!container
ConditionVirtualization=|wsl
Adjtimex
apt-get install adjtimex

Avant de faire une manip

adjtimex -u -l=/var/log/clocks.log

Voir http://www.linux-france.org/article/sys/heure/ch3.html

clocksource

Oracle recommande de changer le “clock source” à tsc pour les VM Linux x86-64.

# cat /sys/devices/system/clocksource/clocksource0/available_clocksource
xen tsc acpi_pm 

If the tsc clock source is available, then set tsc as the current clock source.

echo "tsc" > /sys/devices/system/clocksource/clocksource0/current_clocksource

Using any text editor, append the clocksource directive to the GRUB_CMDLINE_LINUX line in the /etc/default/grub file to retain this clock source setting even after a reboot.

/etc/default/grub

GRUB_CMDLINE_LINUX="rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rhgb quiet numa=off transparent_hugepage=never clocksource=tsc" 

Falsifier la date et l'heure avec faketime

faketime 2016-01-01 gpg --list-keys

Pb

Pb fichier de conf ignoré à cause d'une conf via DHCP

Voir aussi : https://coreos.com/os/docs/latest/configuring-date-and-timezone.html

/var/lib/ntp/ntp.conf.dhcp

ps -ef | grep ntp
ntp       9777     1  0 08:04 ?        00:00:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -c /var/lib/ntp/ntp.conf.dhcp -u 108:113
rm /var/lib/ntp/ntp.conf.dhcp
systemctl restart ntp

ou sur Redhat

rm /var/lib/dhclient/chrony.servers.eth0
systemctl restart chronyd.service
Pb - the NTP socket is in use, exiting
Solution 1
ntpdate -u pool.ntp.org
Solution 2

Arrêt du service (pour libérer le socket réseau UDP) puis

ntpdate -u pool.ntp.org

http://superuser.com/questions/639202/updating-time-ntpdate3108-the-ntp-socket-is-in-use-exiting ntptrace

Pb avec VirtualBox

ConditionFileIsExecutable=!/usr/sbin/VBoxService was not met

# systemctl status systemd-timesyncd
● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
           └─disable-with-time-daemon.conf
   Active: inactive (dead)
Condition: start condition failed at Fri 2019-10-11 11:37:16 CEST; 5min ago
           └─ ConditionFileIsExecutable=!/usr/sbin/VBoxService was not met
     Docs: man:systemd-timesyncd.service(8)
Solution

/lib/systemd/system/systemd-timesyncd.service.d/disable-with-time-daemon.conf

[Unit]
# do not run timesyncd if we have another NTP daemon installed
#ConditionFileIsExecutable=!/usr/sbin/VBoxService
systemctl daemon-reload
systemctl restart systemd-timesyncd
2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki