Link between openssl 'req' command and 'unable to get local issuer certificate'?
Your second command generates a new RSA key and writes it in server.key, along with the self-signed certificate in server.crt.