Hakunin

SIRM_V2

Mar 23rd, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.59 KB | None | 0 0
  1. markort2815@rs68:~$ cd ~
  2. markort2815@rs68:~$ mkdir miniCA
  3. markort2815@rs68:~$ cd miniCA/
  4. markort2815@rs68:~/miniCA$ mkdir certs
  5. markort2815@rs68:~/miniCA$ mkdir newcerts
  6. markort2815@rs68:~/miniCA$ mkdir private
  7. markort2815@rs68:~/miniCA$ mkdir crl
  8. markort2815@rs68:~/miniCA$ touch index.txt
  9. markort2815@rs68:~/miniCA$ touch serial
  10. markort2815@rs68:~/miniCA$ nano serial //upisujemo 01
  11. markort2815@rs68:~/miniCA$ touch crlnumber
  12. markort2815@rs68:~/miniCA$ nano crlnumber //upisujemo 01
  13. markort2815@rs68:~/miniCA$ ls
  14. certs crl index.txt newcerts private serial crlnumber
  15. markort2815@rs68:~/miniCA$ openssl genrsa -out private/cacert.key -des3 4096
  16. Generating RSA private key, 4096 bit long modulus
  17. ........................................................................................................................++
  18. .............................................................................................................................++
  19. e is 65537 (0x10001)
  20. Enter pass phrase for private/cacert.key: password
  21. Verifying - Enter pass phrase for private/cacert.key: password
  22. markort2815@rs68:~/miniCA$ openssl req -new -x509 -key private/cacert.key -out cacert.pem -config openssl.cnf -days 3650
  23. Enter pass phrase for private/cacert.key:
  24. You are about to be asked to enter information that will be incorporated
  25. into your certificate request.
  26. What you are about to enter is what is called a Distinguished Name or a DN.
  27. There are quite a few fields but you can leave some blank
  28. For some fields there will be a default value,
  29. If you enter '.', the field will be left blank.
  30. -----
  31. Ime zemlje (Kod od 2 slova) [RS]:RS
  32. Ime drzave ili provincije (puno ime) [Srbija]:Srbija
  33. Ime lokacije (npr. grada) []:BG
  34. Ime organizacije (npr. preduzece) [Super kompanija]:VISER
  35. Ime organizacione jedinice unutar organizacije []:rt
  36. Kratko ime, tzv. Common Name (tj. ime subjekta) []:miniCA //BITNO!!!
  37. adresa elektronske poste []:[email protected]
  38. markort2815@rs68:~/miniCA$ ls
  39. cacert.pem certs crl crlnumber index.txt newcerts openssl.cnf private serial #cacer.pem!!
  40.  
  41. //UGAO KLIJENTA
  42. markort2815@rs68:~$ mkdir ana
  43. markort2815@rs68:~$ cd ana
  44. markort2815@rs68:~/ana$ openssl genersa -out ana.key -des3 2048
  45. Generating RSA private key, 2048 bit long modulus
  46. ........+++
  47. .......+++
  48. e is 65537 (0x10001)
  49. Enter pass phrase for ana.key: password
  50. Verifying - Enter pass phrase for ana.key: password
  51. markort2815@rs68:~/ana$ cp ../miniCA/openssl.cnf .
  52. Enter pass phrase for ana.key:
  53. You are about to be asked to enter information that will be incorporated
  54. into your certificate request.
  55. What you are about to enter is what is called a Distinguished Name or a DN.
  56. There are quite a few fields but you can leave some blank
  57. For some fields there will be a default value,
  58. If you enter '.', the field will be left blank.
  59. -----
  60. Ime zemlje (Kod od 2 slova) [RS]:RS
  61. Ime drzave ili provincije (puno ime) [Srbija]:Srbija
  62. Ime lokacije (npr. grada) []:BG
  63. Ime organizacije (npr. preduzece) [Super kompanija]:VISER
  64. Ime organizacione jedinice unutar organizacije []:RT
  65. Kratko ime, tzv. Common Name (tj. ime subjekta) []:[email protected] //ide njen mejl
  66. adresa elektronske poste []:[email protected]
  67. markort2815@rs68:~/ana$ cp ana.csr ../miniCA
  68. markort2815@rs68:~/ana$ cd ../miniCA/
  69. //POTPISUJEMO SERTIFIKAT
  70. markort2815@rs68:~/miniCA$ openssl ca -in ana.csr -config openssl.cnf -out certs/ana.pem
  71. Using configuration from openssl.cnf
  72. Enter pass phrase for /home/LABNET/markort2815/miniCA/private/cacert.key:
  73. Check that the request matches the signature
  74. Signature ok
  75. The Subject's Distinguished Name is as follows
  76. countryName :PRINTABLE:'RS'
  77. stateOrProvinceName :PRINTABLE:'Srbija'
  78. localityName :PRINTABLE:'BG'
  79. organizationName :PRINTABLE:'VISER'
  80. organizationalUnitName:PRINTABLE:'RT'
  81. commonName :T61STRING:'[email protected]'
  82. emailAddress :IA5STRING:'[email protected]'
  83. Certificate is to be certified until Mar 23 15:48:44 2019 GMT (365 days)
  84. Sign the certificate? [y/n]:y
  85.  
  86.  
  87. 1 out of 1 certificate requests certified, commit? [y/n]y
  88. Write out database with 1 new entries
  89. Data Base Updated
  90.  
  91. markort2815@rs68:~/miniCA$ cp certs/ana.pem ../ana/
  92. markort2815@rs68:~/miniCA$ cd ../ana/
  93. markort2815@rs68:~/ana$ openssl pkcs12 -export -in ana.pem -inkey ana.key -name "Anin privatni kljuc i sertifikat" -out ana.p12
  94. Enter pass phrase for ana.key:
  95. Enter Export Password: //SIFRA ZA ANU, onaj ko se ovoga dokopa moze da se predstavlja kao ana
  96. Verifying - Enter Export Password:
  97.  
  98. //pokusavamo da potrvdimo da li anin sertivfikat vazi
  99. markort2815@rs68:~$ rm -r bob //ukoliko vec postoji bob
  100. markort2815@rs68:~$ mkdir bob
  101. markort2815@rs68:~/bob$ cp ../ana/ana.pem .
  102. markort2815@rs68:~/bob$ cp ../miniCA/cacert.pem .
  103. markort2815@rs68:~/bob$ openssl verify ana.pem
  104. ana.pem: C = RS, ST = Srbija, O = VISER, OU = RT, CN = [email protected], emailAddress = [email protected]
  105. error 20 at 0 depth lookup:unable to get local issuer certificate //ne radi zato sto nemamo folder certs
  106. markort2815@rs68:~/bob$ openssl verify -CAfile cacert.pem ana.pem
  107. ana.pem: OK //sad radi
  108. markort2815@rs68:~/bob$ openssl verify -CAfile cacert.pem -purpose sslclient ana.pem
  109. ana.pem: C = RS, ST = Srbija, O = VISER, OU = RT, CN = [email protected], emailAddress = [email protected]
  110. error 26 at 0 depth lookup:unsupported certificate purpose //ssl klijent verifikacija znaci da webserver autentifikuje nas!
  111. OK //obicno na internetu mi autentifikujemo sajt a ne on nas
  112. markort2815@rs68:~/bob$ openssl verify -CAfile cacert.pem -purpose sslserver ana.pem
  113. ana.pem: OK //NEGDE JE GRESKA U .cnf FAJLU ANA NE SME DA BUDE OK!?!?!??!?
Add Comment
Please, Sign In to add comment