Thanks for all ... but it doesn't work...
Here is the script to create CA (your script if I don't have make mistake):
----------------------
openssl genrsa -out mikroTik.ca.key.pem 2048
openssl req -new -x509 -nodes -days 9999 -key mikroTik.ca.key.pem -out mikroTik.ca.cert.pem
----------------------
Here is the script to create Mikrotik certificate:
----------------------
echo "Create certif server"
echo "File name ?".
echo "Do not enter final .crt"
echo "Example: 1-2-3-4"
read SERVER
openssl genrsa -des3 -out $SERVER.key 4096
openssl req -new -key $SERVER.key -out $SERVER.csr
openssl x509 -req -days 3650 -in $SERVER.csr -CA mikroTik.ca.cert.pem -CAkey mikroTik.ca.key.pem -set_serial 01 -out $SERVER.crt
# We delete password in private key:
openssl rsa -in $SERVER.key -out $SERVER-WITH_PRIVATE_KEY_WITHOUT_PSWD.pem2
# Convert to PKCS12:
openssl pkcs12 -export -in $SERVER.crt -inkey $SERVER.key -out $SERVER.pfx
# Convert to pkcs12 p12:
cp $SERVER.pfx $SERVER.p12
# Convert to pkcs7 (extension .p7c) - DER type
openssl x509 -in $SERVER.crt -out $SERVER-PEM_2.pem
# Convert to pkcs12 type PEM - with private key
openssl pkcs12 -in $SERVER.p12 -out $SERVER-with-priv-key.pem
# Convert to pkcs12 type PEM - without private key
openssl pkcs12 -in $SERVER.p12 -out $SERVER-without-priv-key.pem -nokeys
----------------------
I use this script to create 2 certificates (my tunnel will be between 10.0.0.10/8 et 10.0.0.11/8):
- for Mikrotik 10.0.0.10
- for Mikrotik 10.0.0.11
Here is the example for 10.0.0.11:
---------------------------
root@debian:# sh ./create-certif-server
Create certif server
File name ?
Do not enter final .crt
Example: 1-2-3-4
10-0-0-11
Generating RSA private key, 4096 bit long modulus
........................++
.........++
e is 65537 (0x10001)
Enter pass phrase for 10-0-0-11.key:
Verifying - Enter pass phrase for 10-0-0-11.key:
Enter pass phrase for 10-0-0-11.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:10.0.0.11
Email Address []:
10-0-0-11@t.local
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Signature ok
subject=/C=AU/ST=Some-State/O=Internet Widgits Pty Ltd/CN=10.0.0.11/emailAddress=
10-0-0-11@t.local
Getting CA Private Key
Enter pass phrase for 10-0-0-11.key:
writing RSA key
Enter pass phrase for 10-0-0-11.key:
Enter Export Password:
Verifying - Enter Export Password:
Enter Import Password:
MAC verified OK
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
Enter Import Password:
MAC verified OK
---------------------------
With Filezilla, I put all theese certificates in the two Mikrotik.
In each Mikrotik, with System > Certificate > Import, I select:
- mikroTik.ca.cert.pem
- and mikroTik.ca.key.pem
Automatically, I see then "KR" in the first row.
Then I select:
- 10-0-0-10-without-priv-key.pem ("with" don't change anything),
- 10-0-0-10-WITH_PRIVATE_KEY_WITHOUT_PSWD.pem2
Automatically, I see then "KR" in the first row.
I do the same think for 10.0.0.11.
I don't modify the name cert2 and cert3, CA is checked at the bottom of the details windows.
Then, I go in IP > IPSEC > Peers.
In Mikrotik(1) 10.0.0.10, I select:
- Address: 10.0.0.11,
- Auth method: RSA signature,
- Certificate: cert2 (10.0.0.10)
- Remote Certificate: cert3 (10.0.0.11)
- Exchange pode: aggressive
- My ID User FQDN: 10.0.0.10
In Mikrotik(2) 10.0.0.11, I select:
- Address: 10.0.0.10,
- Auth method: RSA signature,
- Certificate: cert3 (10.0.0.11)
- Remote Certificate: cert2 (10.0.0.10)
- Exchange pode: aggressive
- My ID User FQDN: 10.0.0.11
If a XP (192.168.0.1: gateway Mikrotik(1) 192.168.0.10)
try to ping 172.17.0.1 (an other XP that have for gateway Mikrotik(2) 172.16.0.10),
it does't work: in log of the Mikrotik(2), I have:
"ipsec,debug failed to get my CERT."
I hope I don't have make a great mistake and make loosing time of theim trying to help me.
Thanks for all.
Best regards.