I found the cause of the problem: the server time was behind. That can be checked with:
timedatectl
then you can synchronize the time with NTP (Network Time Protocol) servers in Ubuntu the following way:
timedatectl set-ntp yes
Once I did that. everything worked