The problem maybe the /etc/hostname file was created without the linefeed character.
Then, change it manually, adding the linefeed at the end of that line, and after, create your certificates.
Depending on your server, this file could go back to the previous version alone, automatically.
If so, to solve it, you can set the immutable attribute of the file (after your changes):
# chattr +i /etc/hostname
Regards,
Netino