Domanda

Sto cercando di creare una CA falsa e di firmare un certificato da utilizzare con Stunnel (che sembra chiamare le routine OpenSSL, quindi probabilmente non devi conoscere il programma per aiutarti :). Tuttavia, stunnel continua a rifiutare il mio certificato dicendo che non è firmato con la chiave giusta!

Ecco come sto generando le mie chiavi e certificati con OpenSSL:

openssl genrsa -out ca_key.pem 1024

openssl req -config ./root2.cfg -new -sha1 -x509 -key ca_key.pem -out ca_cert.pem -subj "/CN=blah.blah.com/OU=Dev blah CA/C=CA/ST=blah/L=blah/O=Blah Software"

openssl genrsa -out MPS_key.pem 1024

openssl req -config ./MPS2.cfg -new -sha1 -key MPS_key.pem -out MPS_cert_req.pem -subj "/CN=blah.blah.com/OU=blah Certificate/C=CA/ST=blah/L=blah/O=Blah Software"

openssl x509 -req -in MPS_cert_req.pem -signkey ca_key.pem -out MPS_cert.pem -extensions MPS_ext

Quindi il mio stunnel.conf ha queste voci:

CAfile = ca_cert.pem
key = MPS_key.pem
cert = MPS_cert.pem

Quando provo ad avviare lo stunnel ottengo la chiave generica di OpenSSL " non corrisponde al certificato " Errore:

2009.09.09 16:36:04 LOG3[492:172]: SSL_CTX_use_RSAPrivateKey_file: B080074: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch

Ho fatto qualcosa di sbagliato nel generare i miei file?

È stato utile?

Soluzione

Riassumerò ciò che hai impostato:

  1. Hai un " CA " certificato, che è autofirmato.
  2. Hai MPS_cert, che è autofirmato.
  3. Hai firmato MPS_cert usando la chiave CA.

Se leggi il riferimento per il comando x509 di OpenSSL ( http://openssl.org/docs /apps/x509.html ) vedrai che il parametro -signkey indica a OpenSSL di autofirmare il certificato fornito con la chiave privata fornita. Questo non è quello che vuoi.

Quello che vuoi fare è creare una CA autofirmata e quindi usarla per firmare il tuo CSR e generare un certificato valido.

openssl verify ca_cert.pem
ca_cert.pem: /CN=blah.blah.com/OU=Dev blah CA/C=CA/ST=blah/L=blah/O=Blah Software
error 18 at 0 depth lookup:self signed certificate
OK

openssl verify MPS_cert.pem
MPS_cert.pem: /CN=blah.blah.com/OU=blah Certificate/C=CA/ST=blah/L=blah/O=Blah Software
error 18 at 0 depth lookup:self signed certificate
OK

Le opzioni pertinenti sono -CA, -CAkey e -set_serial

openssl x509 -CA ca_cert.pem -CAkey ca_key.pem -set_serial 1 -req -in MPS_cert_req.pem -out MPS_cert2.pem -days 365

Questo dovrebbe comportare un certificato che è firmato dalla tua CA, che è esso stesso autofirmato.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top