Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2018
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.31 KB | None | 0 0
  1. #
  2.  
  3. ##::[[--- Windows OpenSSL Config ---]]::##
  4.  
  5. #####################################################################
  6. ##----- Notes -----##
  7. #####################################################################
  8.  
  9. # All commands required can be found beginning on line 430
  10.  
  11.  
  12. # BSD/Linux/Mac users:
  13.  
  14. # Replace all single/double backslashes with forward slashes. You may also wish to utilize lowercase only,
  15. # and if utilizing spaces in names, ensure utilization of proper break format, i.e. './Sophos\ UTM\ CA.crt'
  16.  
  17. # Ensure EOLs are LF, not CRLF
  18. # Windows uses CRLF, UNIX utilizes LF
  19.  
  20.  
  21. # Sophos users:
  22.  
  23. # If not using SANs, prior to generating user certs, ensure 'x509_extensions = usr_cert_not_dn'
  24. # This results with 'RFC822 Name = user@email.com' in the SubjectAlternativeName of the certificate.
  25. # Without this, it will be impossible to authenticate to VPNs on Sophos.
  26.  
  27. # Intermediate CAs & Intermediate CA client certs CANNOT be utilized on Sophos UTM due to how Sophos authenticates.
  28. # Only exception is the WebAdmin certificate, which can be signed by a Public ICA authority for a FQDN.
  29. # For chain of trust to be maintained, CA & ICA must be installed on devices accessing the WebAdmin/User Portal.
  30.  
  31.  
  32. #####################################################################
  33. ##----- Establish Build Variables -----##
  34. #####################################################################
  35.  
  36. dir = .
  37. cnf = /etc/ssl/openssl.cnf
  38. CNF = $dir\\openssl.cnf
  39.  
  40.  
  41. #####################################################################
  42. ##----- Establish CA Profile and Policy -----##
  43. #####################################################################
  44.  
  45. [ default ]
  46. UTM = "Sophos UTM CA"
  47. WRT = "Router 2 ICA"
  48. VPN = "Router 2 VPN ICA"
  49.  
  50. [ ca ]
  51. default_ca = CA_default
  52.  
  53.  
  54. #####################################################################
  55.  
  56. [ CA_default ]
  57. certs = $dir\\cert
  58. new_certs_dir = $dir
  59.  
  60. database = $dir\\index
  61. RANDFILE = $dir\\rand
  62. serial = $dir\\serial
  63.  
  64. crldir = $dir\\crl
  65. crlnumber = $crldir\\crlnumber
  66. crl = $crldir\\ca.crl.pem
  67. default_crl_days = 3650
  68.  
  69. certificate = "$dir\\ca\\$UTM.crt.pem"
  70. private_key = "$dir\\ca\\$UTM.key.pem"
  71.  
  72. default_days = 3650
  73. preserve = no
  74. default_md = sha512
  75.  
  76. x509_extensions = usr_cert_not_dn
  77. copy_extensions = copy
  78. unique_subject = yes
  79.  
  80. policy = policy_match
  81. name_opt = esc_2253,esc_ctrl,esc_msb,sep_comma_plus_space,ignore_type
  82. cert_opt = ca_default
  83.  
  84.  
  85. #####################################################################
  86.  
  87. [ policy_match ]
  88. countryName = match
  89. stateOrProvinceName = match
  90. organizationName = match
  91. organizationalUnitName = match
  92. commonName = supplied
  93. emailAddress = optional
  94.  
  95. [ policy_supply ]
  96. countryName = match
  97. stateOrProvinceName = match
  98. organizationName = match
  99. organizationalUnitName = match
  100. commonName = optional
  101. emailAddress = optional
  102.  
  103.  
  104. #####################################################################
  105. ##----- Establish Certificate Options -----#
  106. #--------------------------------------------------------------------
  107.  
  108. # If you plan on using TLS ECDHE or ECDH, the bits and hash must exceed the value you wish to have.
  109.  
  110. # For example, if one wants 2048bit encryption with a SHA256 hash, encryption value must be
  111. # greater than 2048 (3072 or 4096) with a hash greater than SHA256 (SHA384 or SHA512).
  112. # x64 machines can almost always process SHA512 faster than SHA256.
  113.  
  114. # If you're not planning on using TLS ECDHE or ECDH, a key larger than 2048bit isn't necessary.
  115.  
  116. # Encrypt key is not currently commmented out; however, as one does not want a server's key to have
  117. # an encrypted password, when creating the key for the server, add -nodes to the Request command.
  118.  
  119.  
  120. [ req ]
  121. default_bits = 2048
  122. default_keyfile = private.key.pem
  123.  
  124. preserve = no
  125. default_md = sha512
  126.  
  127. string_mask = utf8only
  128. utf8 = yes
  129. distinguished_name = req_distinguished_name
  130. attributes = req_attributes
  131. req_extensions = v3_req
  132. x509_extensions = v3_ca
  133. copy_extensions = copy
  134. encrypt_key = yes
  135.  
  136. [ req_attributes ]
  137. challengePassword =
  138. challengePassword_min = 12
  139. challengePassword_max = 40
  140.  
  141.  
  142. #####################################################################
  143.  
  144. [ req_distinguished_name ]
  145.  
  146. countryName = Country
  147. countryName_max = 2
  148. stateOrProvinceName = State
  149. localityName = Locality
  150. 0.organizationName = Organization
  151. organizationalUnitName = Organizational Unit
  152. commonName = Common Name
  153. commonName_max = 64
  154. emailAddres = Email
  155. emailAddress_max = 64
  156.  
  157. countryName_default = xx
  158. stateOrProvinceName_default = State
  159. localityName_default = Locality
  160. 0.organizationName_default = Sophos UTM
  161. organizationalUnitName_default = LAN
  162.  
  163.  
  164. #####################################################################
  165. ##----- Establish SubjectAltName (SAN) Profiles -----##
  166. #####################################################################
  167.  
  168. # All server certs with WebUIs should have their loopback IP specified in their SAN profile
  169. # This prevents certificate errors if connecting to the device, router, or server via an SSH tunnel
  170. # Certain OS CA certs must have the loopback IP specified in SAN profile (i.e. Sophos UTM's CA)
  171.  
  172. # Provided one utilizes the SAN profile, Common Names can be whatever one wishes (i.e. not the DNS or IP)
  173. # SANs can be: email (an email address), URI (a uniform resource indicator), DNS (a DNS domain name),
  174. # RID (a registered ID: OBJECT IDENTIFIER), IP (an IP address), dirName (a distinguished name), and otherName.
  175.  
  176.  
  177. #--------------------------------------------------------------------
  178. ##----- Certificate Authorities -----##
  179. #--------------------------------------------------------------------
  180.  
  181. # Main #
  182. [ alt_ca_main ]
  183. DNS.1 = Router.1
  184. IP.1 = 127.0.0.1
  185.  
  186. # Router 2 #
  187. [ alt_ica_router2 ]
  188. DNS.1 = Router.2
  189. IP.1 = 127.0.0.1
  190.  
  191. # Code Signing #
  192. [ alt_signing_ica ]
  193. DNS.1 = Code-Signing
  194.  
  195. #--------------------------------------------------------------------
  196. ##----- Certificate Authority Clients -----##
  197. #--------------------------------------------------------------------
  198.  
  199. # Main #
  200.  
  201. # Servers #
  202. [ alt_sophos ]
  203. IP.1 = 192.168.2.1
  204. IP.2 = 127.0.0.1
  205. DNS.1 = UTM.LEDE
  206. DNS.2 = your.ddns.com
  207.  
  208. [ alt_freenas ]
  209. IP.1 = 192.168.2.13
  210. IP.2 = 192.168.2.130
  211. IP.3 = 127.0.0.1
  212. DNS.1 = Free.LEDE
  213. DNS.2 = your-fqdn.com
  214.  
  215. [ alt_vpn_server1 ]
  216. IP.1 = 10.0.0.1
  217. DNS.1 = your.ddns.com
  218.  
  219. # Clients #
  220. [ alt_vpn1_user1 ]
  221. email.1 = user1@email.com
  222. DNS.1 = VPN1-Client1-Device-Hostname1
  223. DNS.2 = VPN1-Client1-Device-Hostname2
  224.  
  225.  
  226. #--------------------------------------------------------------------
  227. ##----- Intermediate Certificate Authority Clients -----##
  228. #--------------------------------------------------------------------
  229.  
  230. # Router 2 #
  231.  
  232. # Servers #
  233. [ alt_lede ]
  234. IP.1 = 192.168.2.2
  235. IP.2 = 127.0.0.1
  236. DNS.1 = LAN.LEDE
  237.  
  238. [ alt_vpn_server2 ]
  239. IP.1 = 10.0.1.1
  240. DNS.1 = your.ddns.com
  241.  
  242. # Clients #
  243. [ alt_vpn2_user1 ]
  244. DNS.1 = VPNserver-Client1-Device-Hostname
  245. email.1 = user1@email.com
  246.  
  247. [ alt_vpn2_user2 ]
  248. DNS.1 = VPN2-Client2-Device-Hostname1
  249. DNS.2 = VPN2-Client2-Device-Hostname2
  250. email.1 = user2@email.com
  251.  
  252.  
  253. # Code Signing #
  254.  
  255. # Cert1 #
  256. [ alt_codesign ]
  257. email.1 = user@email.com
  258.  
  259.  
  260. #####################################################################
  261. ##----- Establish Certificate Authority V3 Profiles -----##
  262. #--------------------------------------------------------------------
  263.  
  264. # These V3 CA profiles must not be modified to contain any more, or any less, KUs
  265.  
  266. # These have been configured specifically for security & its imperative no other keyUsages are set
  267. # For an ICA to be capable of signing additional CAs/ICAs, pathlen number must mirror number of CAs/ICAs
  268. # it can sign. By default, all ICAs are set to 0, meaning they can sign certs, but not other CAs/ICAs.
  269.  
  270.  
  271. [ v3_ca ]
  272. basicConstraints = critical, CA:TRUE
  273. subjectKeyIdentifier = hash
  274. authorityKeyIdentifier = keyid:always, issuer:always
  275. subjectAltName = @alt_ca_main
  276. keyUsage = critical, cRLSign, digitalSignature, keyCertSign
  277.  
  278. [ v3_ica_router2 ]
  279. basicConstraints = critical, CA:TRUE, pathlen:0
  280. subjectKeyIdentifier = hash
  281. authorityKeyIdentifier = keyid:always, issuer:always
  282. subjectAltName = @alt_ica_router2
  283. keyUsage = critical, cRLSign, digitalSignature, keyCertSign
  284.  
  285. [ v3_signing_ica ]
  286. basicConstraints = critical, CA:TRUE, pathlen:0
  287. subjectKeyIdentifier = hash
  288. authorityKeyIdentifier = keyid:always, issuer:always
  289. keyUsage = critical, cRLSign, digitalSignature, keyCertSign
  290. subjectAltName = @alt_signing_ica
  291.  
  292. [ crl_ext ]
  293. issuerAltName = issuer:copy
  294. authorityKeyIdentifier = keyid:always, issuer:always
  295.  
  296.  
  297. #####################################################################
  298. ##----- Establish Generalized V3 Certificate Profiles -----##
  299. #--------------------------------------------------------------------
  300.  
  301. [ v3_req ]
  302. basicConstraints = critical, CA:FALSE
  303. subjectKeyIdentifier = hash
  304.  
  305. [ usr_cert_dn ]
  306. basicConstraints = critical, CA:FALSE
  307. subjectKeyIdentifier = hash
  308. authorityKeyIdentifier = keyid:always, issuer:always
  309. keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment
  310. extendedKeyUsage = critical, clientAuth, emailProtection
  311.  
  312. [ usr_cert_not_dn ]
  313. basicConstraints = critical, CA:FALSE
  314. subjectKeyIdentifier = hash
  315. authorityKeyIdentifier = keyid:always, issuer:always
  316. subjectAltName = email:copy
  317. keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment
  318. extendedKeyUsage = critical, clientAuth, emailProtection
  319.  
  320.  
  321. #####################################################################
  322. ##----- Establish Client Certificate V3 Profiles -----##
  323. #--------------------------------------------------------------------
  324.  
  325. # These V3 profiles should not be modified to contain less than what they are currently configured with.
  326. # These have been specifically configured with security in mind.
  327.  
  328. # All servers capable of TLS should contain all keyUsages, except for dataEncipherment
  329. # VPN and file servers should not have less than digitalSignature, keyEncipherment, keyAgreement
  330.  
  331. # All servers must contain EKU serverAuth
  332. # All server [VPN] clients must contain EKU clientAuth
  333.  
  334.  
  335. #--------------------------------------------------------------------
  336. ##----- Certificate Authority Clients -----##
  337. #--------------------------------------------------------------------
  338.  
  339. # Main #
  340.  
  341. # Servers #
  342. [ v3_sophos ]
  343. basicConstraints = critical, CA:FALSE
  344. subjectKeyIdentifier = hash
  345. authorityKeyIdentifier = keyid:always, issuer:always
  346. keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment, keyAgreement
  347. extendedKeyUsage = critical, serverAuth
  348. subjectAltName = @alt_sophos
  349.  
  350. [ v3_freenas ]
  351. basicConstraints = critical, CA:FALSE
  352. subjectKeyIdentifier = hash
  353. authorityKeyIdentifier = keyid:always, issuer:always
  354. keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment, keyAgreement
  355. extendedKeyUsage = critical, serverAuth
  356. subjectAltName = @alt_freenas
  357.  
  358. [ v3_vpn_server1 ]
  359. basicConstraints = critical, CA:FALSE
  360. subjectKeyIdentifier = hash
  361. authorityKeyIdentifier = keyid:always, issuer:always
  362. keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment, keyAgreement
  363. extendedKeyUsage = critical, serverAuth
  364. subjectAltName = @alt_vpn_server1
  365.  
  366. # Clients #
  367. [ v3_vpn1_user1 ]
  368. basicConstraints = critical,CA:FALSE
  369. subjectKeyIdentifier = hash
  370. authorityKeyIdentifier = keyid:always, issuer:always
  371. keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment
  372. extendedKeyUsage = critical, clientAuth
  373. subjectAltName = @alt_vpn1_user1
  374.  
  375.  
  376. #--------------------------------------------------------------------
  377. ##----- Intermediate Certificate Authority Clients -----##
  378. #--------------------------------------------------------------------
  379.  
  380. # Router 2 #
  381.  
  382. # Servers #
  383. [ v3_lede ]
  384. basicConstraints = critical, CA:FALSE
  385. subjectKeyIdentifier = hash
  386. authorityKeyIdentifier = keyid:always, issuer:always
  387. keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment, keyAgreement
  388. extendedKeyUsage = critical, serverAuth
  389. subjectAltName = @alt_lede
  390.  
  391. [ v3_vpn_server2 ]
  392. basicConstraints = critical, CA:FALSE
  393. subjectKeyIdentifier = hash
  394. authorityKeyIdentifier = keyid:always, issuer:always
  395. keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment, keyAgreement
  396. extendedKeyUsage = critical, serverAuth
  397. subjectAltName = @alt_vpn_server2
  398.  
  399. # Clients #
  400. [ v3_vpn2_user1 ]
  401. basicConstraints = critical,CA:FALSE
  402. subjectKeyIdentifier = hash
  403. authorityKeyIdentifier = keyid:always, issuer:always
  404. keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment
  405. extendedKeyUsage = critical, clientAuth
  406. subjectAltName = @alt_vpn2_user1
  407.  
  408. [ v3_vpn2_user2 ]
  409. basicConstraints = critical,CA:FALSE
  410. subjectKeyIdentifier = hash
  411. authorityKeyIdentifier = keyid:always, issuer:always
  412. keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment
  413. extendedKeyUsage = critical, clientAuth
  414. subjectAltName = @alt_vpn2_user2
  415.  
  416.  
  417. # Code Signing #
  418.  
  419. # Certificates #
  420. [ v3_codesign ]
  421. basicConstraints = critical, CA:FALSE
  422. subjectKeyIdentifier = hash
  423. authorityKeyIdentifier = keyid:always, issuer:always
  424. keyUsage = critical, nonRepudiation, digitalSignature
  425. extendedKeyUsage = critical, codeSigning, msCodeInd, msCodeCom, mcCTLSign, timeStamping
  426. subjectAltName = @alt_codesign
  427.  
  428.  
  429.  
  430. #####################################################################
  431. #--------------------------------------------------------------------
  432. ##----- OpenSSL Commands -----##
  433. #--------------------------------------------------------------------
  434. #####################################################################
  435.  
  436. # Prerequisistes:
  437.  
  438. # 1. Create 'serial' file: echo 00 > serial
  439.  
  440. # This file maintains the serial for the most recent cert, in order to know what serial to next assign.
  441. # Serial is in hex, not dec[imal] format, & one can choose whichever number one wishes to start at.
  442.  
  443. # 2. Create 'crlnumber' file: mkdir crl && echo 01 > crl\crlnumber
  444.  
  445. # This file maintains the current serial for the CRL [Certificate Revocation List] certificate
  446. # A CRL should be generated, but will not be used until one revokes a certificate via one's CA or ICA
  447.  
  448. # 3. Create 'index' file (leave blank): echo > index
  449.  
  450. # This file maintains an index of all certificates issued and is covered under the Index Section below
  451. # Maintains a record of all certs issued, and is extremely important if one has revoked a certificate.
  452.  
  453. # 4. Create 'rand' file (leave blank): echo > rand
  454.  
  455. # File is utilized by for random characters & is querried by openssl during certificate/key creation.
  456.  
  457.  
  458. # ENCRYPT_KEY [Establish Certificate Options] is not currently commented out; Server cert keys should not
  459. # be created with encryption, so add the additional command option to key creation: -nodes
  460.  
  461. # Encrypting a server key will result in the server requiring the passkey every time it's started/restarted;
  462. # in other words, a massive inconvenience, and potentially destrimental.
  463.  
  464.  
  465. # Provided you utilize the SubjectAltName (SAN) section [highly recommended], the Common Name is not required
  466. # to be the IP/DNS/FQDN, and can be whatever name you wish it to be
  467.  
  468.  
  469. #####################################################################
  470. #--------------------------------------------------------------------
  471. #####################################################################
  472.  
  473. # For VPN Server certs:
  474. # When creating a VPN server cert using 'extendedKeyUsage = serverAuth', in your VPN client config you must
  475. # change "remote-cert-tls server" to "remote-cert-eku 'TLS Web Server Authentication'" ( see https://www.v13.gr/blog/?p=386 )
  476.  
  477. # For BSD/*nix OSes:
  478. # Certificates should have 644 permissions
  479. # chmod 644 ./certificate.crt.pem
  480.  
  481. # Keys should have 600 permissions
  482. # chmod 600 ./certificate.key
  483.  
  484.  
  485. #--------------------------------------------------------------------
  486. ## ----- Certificate Authority ----- ##
  487. #--------------------------------------------------------------------
  488.  
  489. # Generate CA:
  490.  
  491. # CA key should have a secure password of at least 20 characters, containing at least:
  492. # 2 uppercase letters, 2 lowercase letters, 2 numbers, and 2 symbols
  493.  
  494.  
  495. # Request:
  496. # openssl req -x509 -new -sha512 -days 3650 -newkey rsa:4096 -keyout CA.key.pem -out CA.crt.pem -config .\openssl.cnf -extensions v3_ca
  497.  
  498. # Generate CA CRL Cert:
  499. # openssl ca -gencrl -keyfile CA.key.pem -cert CA.crt.pem -out CA.crl.pem -config .\openssl.cnf
  500.  
  501. # Convert CA CRL Cert to DER CRL:
  502. # openssl crl -inform PEM -in '.\CA.crl.pem' -outform DER -out '.\CA.crl'
  503.  
  504.  
  505. #--------------------------------------------------------------------
  506. ## ----- Intermediate Certificate Authority ----- ##
  507. #--------------------------------------------------------------------
  508.  
  509. # Gernerate Intermediate CA:
  510.  
  511. # Intermediate CA key should have a secure password of at least 20 characters, containing at least:
  512. # 2 uppercase letters, 2 lowercase letters, 2 numbers, and 2 symbols
  513.  
  514.  
  515. # Request:
  516. # openssl req -out '.\VPN-ICA.csr' -new -days 3650 -sha512 -newkey rsa:4096 -keyout VPN-ICA.key -config .\openssl.cnf -extensions v3_intermediate_ca
  517.  
  518. # Sign Intermediate CA with CA:
  519. # openssl x509 -req -sha512 -days 3650 -in '.\VPN-ICA.csr' -CA CA.crt.pem -CAkey CA.key -CAserial .\serial -out VPN-ICA.crt.pem -extfile .\openssl.cnf -extensions v3_intermediate_ca
  520.  
  521. # Generate Intermediate CA CRL Cert:
  522. # openssl ca -config .\openssl.cnf -gencrl -keyfile VPN-ICA.key -cert VPN-ICA.crt.pem -out '.\VPN-ICA.crl.pem'
  523.  
  524. # Convert Intermediate CA CRL Cert to DER CRL:
  525. # openssl crl -inform PEM -in '.\VPN-ICA.crl.pem' -outform DER -out '.\VPN-ICA.crl'
  526.  
  527. #--------------------------------------------------------------------
  528.  
  529. # Create Concatenated CA - Intermediate CA Certificate Chain:
  530.  
  531. # Windows:
  532. # cmd /c type '.\Router 2 ICA.crt.pem' '.\Sophos UTM CA.crt.pem' > '.\Sophos VPN CA Chain.pem'
  533.  
  534. # Linux/BSD:
  535. # cat './Router 2 ICA.crt.pem' './Sophos UTM CA.crt.pem' > './Sophos VPN CA Chain.pem'
  536.  
  537. #--------------------------------------------------------------------
  538.  
  539. # Export VPN Client with an Intermediate CA:
  540. # openssl pkcs12 -export -out '.\VPN Client1.p12' -inkey '.\VPN Client1.key.pem' -in '.\VPN Client1.crt.pem' -certfile '.\Sophos VPN CA Chain.crt.pem'
  541.  
  542. # The Intermediate CA is still used to sign the certs it issues, however, the CA - Intermediate CA chain cert must
  543. # be exported with the client cert & key to maintain the chain of trust of Certificate -> Intermediate CA -> CA.
  544. # The certificate path of the client cert should show a hierarchy of CA -> Intermediate CA -> Client.
  545.  
  546.  
  547. #--------------------------------------------------------------------
  548. ## ----- Client Certificate ----- ##
  549. #--------------------------------------------------------------------
  550.  
  551. # For Server certs, add to end of the Request command: -nodes
  552. # If a server cert is created with an encrypted key, one will need to manually type in the encryption password
  553. # whenever starting or restarting the server (inconvenient and impractical for VPN and Web Servers).
  554.  
  555.  
  556. # Request:
  557. # openssl req -out '.\NextCloud.csr' -new -days 3650 -sha512 -newkey rsa:3072 -keyout '.\NextCloud.key.pem' -config .\openssl.cnf -extensions v3_nextcloud -nodes
  558.  
  559. # With multiple common names:
  560. # openssl req -out '.\Sophos-UTM-VPN-client.csr' -new -days 3650 -sha512 -newkey rsa:3072 \
  561. # -subj '/C=US/ST=ST/L=Locality/O=Sophos UTM/OU=LAN/CN=UserName/CN=User.Name/CN=User_Name/emailAddress=whatever@whichever.com' \
  562. # -keyout '.\Sophos-UTM-VPN-client.key.pem' -config .\openssl.cnf -extensions v3_vpn_client
  563.  
  564. # Sign:
  565. # openssl x509 -req -sha512 -days 3650 -in '.\WRT1900ac.csr' -CA '.\Sophos UTM CA.crt.pem' -CAkey '.\Sophos UTM CA.key.pem' -CAserial .\serial -out '.\crt\WRT1900ac.crt.pem' -extfile .\openssl.cnf -extensions v3_nextcloud
  566.  
  567. # Export:
  568. # openssl pkcs12 -export -out '.\NextCloud.p12' -inkey '.\NextCloud.key.pem' -in '.\NextCloud.crt.pem' -certfile CA.crt.pem
  569.  
  570.  
  571. #--------------------------------------------------------------------
  572. ## ----- Verification of Certificates ----- ##
  573. #--------------------------------------------------------------------
  574.  
  575. # Verify Certificate Signing Request (CSR):
  576. # openssl req -text -noout -verify -in CSR.csr
  577.  
  578. # Verify Private Key:
  579. # openssl rsa -check -in private.key
  580.  
  581. # Verify Certificate:
  582. # openssl x509 -text -noout -in certificate.crt
  583.  
  584. # Verify PKCS12 Certificate [.pfx/.p12]:
  585. # openssl pkcs12 -info -in certificate.p12
  586.  
  587.  
  588. #--------------------------------------------------------------------
  589. ## ----- Intermediate CA Android Build Certificates ----- ##
  590. #--------------------------------------------------------------------
  591.  
  592. # This will apply to the following six certificates: media, platform, releasekeys, shared, superuser, testkey
  593. # the following steps will need to be repeated for each of the six
  594.  
  595.  
  596. # Generate Individual intermediate Build CA Request:
  597. # openssl req -out '.\media.csr' -new -days 3650 -sha512 -config .\openssl.cnf -extensions v3_intermediate_ca -newkey rsa:4096f4 -ouform PEM -keyout '.\media.key.pem'
  598.  
  599. # Convert PEM key to PK8:
  600. # openssl pkcs8 -in media.key.pem -topk8 -outform DER -out media.pk8 -nocrypt
  601.  
  602. # Sign Individual intermediate Build CA Request:
  603. # openssl x509 -req -sha512 -days 3650 -in '.\media.csr' -CA CA.crt.pem -CAkey CA.key -CAserial .\serial -out '.\media.x509.pem' -extfile .\openssl.cnf -extensions v3_intermediate_ca
  604.  
  605. # Generate Individual intermediate Build CA CRL Cert:
  606. # openssl ca -config .\openssl.cnf -gencrl -keyfile '.\media.key.pem' -cert '.\media.x509.pem' -out '.\media.crl.pem' -extfile '.\openssl.cnf' -extensions crl_ext
  607.  
  608. # Convert Individual intermediate Build CA CRL Cert to DER crl:
  609. # openssl crl -inform PEM -in '.\media.crl.pem' -outform DER -out '.\media.crl'
  610.  
  611. #--------------------------------------------------------------------
  612.  
  613. # Concatenated Intermediate Build CA - CA PEM Certificate:
  614.  
  615. # Windows:
  616. # cmd /c type 'media.x509.pem' 'Sophos UTM CA.crt.pem' > 'Android-Media-CA-Chain.pem'
  617.  
  618. # Linux/BSD:
  619. # cat './media.x509.pem' './Sophos UTM CA.crt.pem' > './Android-Media-CA-Chain.pem'
  620.  
  621. #--------------------------------------------------------------------
  622.  
  623. # Create PKCS12 for Import into Keystore:
  624. # openssl pkcs12 -export -out .\media.p12 -inkey .\media.key.pem -in .\media.x509.pem -certfile '.\Android-Media-CA-Chain.pem' -password pass:media -name media
  625.  
  626. # The Intermediate CA is still used to sign packages/images, however, the CA - Intermediate CA chain cert
  627. # must be exported with the client cert & key to maintain the certificate chain of trust of: Package/Image -> Intermediate CA -> CA
  628.  
  629. # Copy the following files into your build directory (location will vary depending on ROM):
  630.  
  631. # For each of the six: *.x509.pem, *.pk8, Android-*-CA-Chain.pem, *.p12
  632. # i.e. media.x509.pem, media.pk8, Android-Media-CA-Chain.pem, media.p12
  633.  
  634.  
  635. # One example of how to import into keystore prior to build:
  636. # Source: http://stackoverflow.com/questions/22212869/how-can-i-generate-an-android-keystore-from-a-key-pk8-and-certificate-pem
  637.  
  638. # keytool -importkeystore -deststorepass password -destkeystore .keystore -srckeystore media.p12 -srcstoretype PKCS12 -srcstorepass media
  639. # keytool -list -v -keystore .keystore
  640.  
  641.  
  642. #####################################################################
  643. #--------------------------------------------------------------------
  644. #####################################################################
  645.  
  646. ##---- Index File -----##
  647. #--------------------------------------------------------------------
  648.  
  649. # If you wish to maintain the index file automatically, you'll need to use 'openssl ca' to sign certs.
  650. # You can manually maintain the index file, by inputting 1 cert entry per line in the following format:
  651.  
  652. # V 261231235959Z 0a unknown /C=US/ST=State/L=Locality/O=Sophos UTM/OU=LAN/CN=Cert Common Name/emailaddress=whatever@whichever.com
  653. # 1 2-----------> 3-> 4-> 5-----> 6--------------------------------------------------------------------------------------------------->
  654.  
  655.  
  656. # 1. Status of Certificate:
  657. # V [Valid] R [Revoked] E [Expired]
  658.  
  659. # 2. Expiration Date:
  660. # Format: YYMMDDHHMMSS followed by 'Z': 2026.12.31 @ 23:59:59
  661.  
  662. # 3. Revocation Date [Format: YYMMDDHHMMSSZ,reason]
  663. # Certain distros error out without a whitespace for 3 in the index file
  664. # Empty if not revoked, otherwise valid reasons are:
  665. # keyCompromise
  666. # CACompromise
  667. # affiliationChanged
  668. # superseded
  669. # cessationOfOperation
  670. # certificateHold
  671. # privilegeWithdrawn
  672. # AACompromise
  673.  
  674. # 4. Serial number in hex format: 0a is hex for 10
  675. # Windows:
  676. # Calculator has programmer feature which can convert dec <-> hex
  677. # Linux/BSD:
  678. # cli hex -> dec:
  679. # printf '%d\n' 0x0a [returns 10]
  680. # cli dec -> hex:
  681. # printf '%x\n' 10 [returns 0a]
  682.  
  683. # 5. Certificate Filename or Literal String
  684. # Certificate filename or literal string 'unknown'
  685.  
  686. # 6. Distinguished Name
  687.  
  688.  
  689. #--------------------------------------------------------------------
  690. #####################################################################
  691. ##----- Key Usage -----##
  692. #--------------------------------------------------------------------
  693.  
  694.  
  695. # !!! CA / ICA ONLY !!! #
  696. #--------------------------------------------------------------------
  697.  
  698. # These extensions MUST ONLY be used for CA / ICA certificates
  699.  
  700. # cRLSign:
  701. # Is asserted when subject public key is used for verifying signatures on certificate revocation lists.
  702.  
  703. # keyCertSign:
  704.  
  705. # Is asserted when subject public key is used for verifying signatures on public key certificates.
  706. # If keyCertSign is asserted, the CA bit in the basic constraints extension (Section 4.2.1.9) MUST also be asserted.
  707.  
  708.  
  709. # All #
  710. #--------------------------------------------------------------------
  711.  
  712. # digitalSignature:
  713.  
  714. # Certificates with this flag set can be used to apply a digital signature. Digital signatures are often used for entity
  715. # authentication and data origin authentication with integrity.
  716. # Is asserted when subject public key is used for verifying digital signatures, other than signatures on certificates
  717. # (bit 5) and CRLs (bit 6).
  718.  
  719. # nonRepudiation:
  720.  
  721. # Certificates with this flag set can be used to sign data as above but the certificate public key may be used to provide
  722. # non-repudiation services preventing the signing entity from falsely denying some action.
  723. # Is asserted when subject public key is used to verify digital signatures, other than signatures on certificates (bit 5)
  724. # and CRLs (bit 6).
  725. # NOTE: Recent editions of X.509 have renamed the nonRepudiation bit to contentCommitment.
  726.  
  727. # keyEncipherment:
  728.  
  729. # Certificates with this flag set may be used by the subject to encrypt a symmetric key which is then transferred to the
  730. # target, decrypted, and subsequently used to encrypt and decrypt data sent between the two entities.
  731. # Is asserted when subject public key is used for enciphering private or secret keys when an RSA public key is to be
  732. # used for encrypting a symmetric content-decryption key or an asymmetric private key.
  733.  
  734. # dataEncipherment:
  735.  
  736. # Certificates with this flag set can be used by the subject to encrypt and decrypt actual application data.
  737. # Is asserted when subject public key is used for directly enciphering raw user data without the use of an intermediate
  738. # symmetric cipher.
  739. # NOTE: Use of this bit extremely uncommon; all applications use key transport / key agreement to establish a symmetric key.
  740.  
  741. # keyAgreement:
  742.  
  743. # Certificates with this flag set enable the subject to use a key agreement protocol, such as Diffie-Hellman, to establish
  744. # a symmetric key with a target that may then be used to encrypt and decrypt data sent between the two entities
  745. # Is asserted when subject public key is used for key agreement (i.e. when a Diffie-Hellman key is used for key management).
  746.  
  747. # encipherOnly:
  748.  
  749. # Undefined in the absence of the keyAgreement bit (keyAgreement is required).
  750. # Public key used only for enciphering data while performing key agreement.
  751. # When encipherOnly is asserted AND keyAgreement also set, subject public key may be used ONLY for enciphering data while
  752. # performing key agreement.
  753.  
  754. # decipherOnly:
  755.  
  756. # Undefined in the absence of the keyAgreement bit (keyAgreement is required).
  757. # Public key used only for deciphering data while performing key agreement.
  758. # When decipherOnly is asserted AND keyAgreement is also set, subject public key may be used ONLY for deciphering data
  759. # while performing key agreement.
  760.  
  761.  
  762. #--------------------------------------------------------------------
  763. ##----- RFC 5280 4.2.1.3 -----##
  764. #--------------------------------------------------------------------
  765.  
  766. # https://tools.ietf.org/html/rfc5280
  767.  
  768. # id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 }
  769.  
  770. # KeyUsage ::= BIT STRING {
  771. # digitalSignature (0),
  772.  
  773. # nonRepudiation (1),
  774. # NOTE: Recent editions of X.509 have renamed this bit to contentCommitment
  775.  
  776. # keyEncipherment (2),
  777. # dataEncipherment (3),
  778. # keyAgreement (4),
  779. # keyCertSign (5),
  780. # cRLSign (6),
  781. # encipherOnly (7),
  782. # decipherOnly (8) }
  783.  
  784.  
  785. #--------------------------------------------------------------------
  786. #####################################################################
  787. ##----- Extended Key Usage -----##
  788. #--------------------------------------------------------------------
  789.  
  790. # serverAuth:
  791.  
  792. # SSL/TLS Web/VPN Server authentication EKU which is assigned to a server and distinguishes them as a server for which
  793. # options, clients can authenticate against. All VPN servers should be signed with this EKU present.
  794. # This supercedes nscertype as the 'ns' in nscertype stands for NetScape [browser], which hasn't existed for some time.
  795.  
  796. # clientAuth:
  797.  
  798. # SSL/TLS Web/VPN Client authentication EKU which is assigned to a server client, and distinguishes them as a client only.
  799. # All VPN clients MUST be signed with this EKU present.
  800.  
  801. # codeSigning:
  802. # Code Signing... self explanatory
  803.  
  804. # emailProtection:
  805. # Email Protection via S/MIME, allows you to send and receive encrypted emails
  806.  
  807. # timeStamping:
  808. # Trusted Timestamping... self explanatory
  809.  
  810. # OCSPSigning:
  811. # OCSP Signing... self explanatory
  812.  
  813.  
  814. # ipsecIKE:
  815.  
  816. # IPSec Internet Key Exchange, of which I believe is in the same boat as the three below; however, some research needs
  817. # to be Performed to determine if this EKU should also no longer be utilized.
  818. # clientAuth can be utilized in a IPSec VPN client cert.
  819.  
  820. # ipsecEndSystem, ipsecTunnel, & ipsecUser:
  821.  
  822. # !!! SHOULD NOT BE UTILIZED !!!
  823.  
  824. # There were three IPsec-related object identifiers in EKU that were assigned in 1999, and the semantics of these
  825. # values were never clearly defined. The use of these three EKU values in IKE/IPsec is obsolete and explicitly
  826. # deprecated by this specification. CAs SHOULD NOT issue certificates for use in IKE with them.
  827.  
  828.  
  829. # msCodeInd:
  830. # Microsoft Individual Code Signing (authenticode)... self explanatory
  831.  
  832. # msCodeCom:
  833. # Microsoft Commerical Code Signing (authenticode)... self explanatory
  834.  
  835. # mcCTLSign:
  836. # Microsoft Trust List Signing... self explanatory
  837.  
  838. # msEFS:
  839. # Microsoft Encrypted File System... self explanatory
  840.  
  841.  
  842.  
  843. #--------------------------------------------------------------------
  844. ##----- RFC 5280 4.2.1.12 -----##
  845. #--------------------------------------------------------------------
  846.  
  847. # https://tools.ietf.org/html/rfc5280
  848.  
  849. # anyExtendedKeyUsage OBJECT IDENTIFIER ::= { id-ce-extKeyUsage 0 }
  850.  
  851. # id-kp OBJECT IDENTIFIER ::= { id-pkix 3 }
  852.  
  853. # id-kp-serverAuth OBJECT IDENTIFIER ::= { id-kp 1 }
  854.  
  855. # TLS WWW server authentication:
  856. # Key usage bits that may be consistent:
  857. # digitalSignature, keyEncipherment or keyAgreement
  858.  
  859. # id-kp-clientAuth OBJECT IDENTIFIER ::= { id-kp 2 }
  860.  
  861. # TLS WWW client authentication:
  862. # Key usage bits that may be consistent:
  863. # digitalSignature and/or keyAgreement
  864.  
  865. # id-kp-codeSigning OBJECT IDENTIFIER ::= { id-kp 3 }
  866.  
  867. # Signing of downloadable executable code
  868. # Key usage bits that may be consistent:
  869. # digitalSignature
  870.  
  871. # id-kp-emailProtection OBJECT IDENTIFIER ::= { id-kp 4 }
  872.  
  873. # Email protection:
  874. # Key usage bits that may be consistent:
  875. # digitalSignature, nonRepudiation, and/or (keyEncipherment or keyAgreement)
  876.  
  877. # id-kp-timeStamping OBJECT IDENTIFIER ::= { id-kp 8 }
  878.  
  879. # Binding the hash of an object to a time
  880. # Key usage bits that may be consistent:
  881. # digitalSignature and/or nonRepudiation
  882.  
  883. # id-kp-OCSPSigning OBJECT IDENTIFIER ::= { id-kp 9 }
  884.  
  885. # Signing OCSP responses:
  886. # Key usage bits that may be consistent:
  887. # digitalSignature and/or nonRepudiation
  888.  
  889.  
  890. #--------------------------------------------------------------------
  891. #####################################################################
  892. ##----- Key Exchange Algorithms -----##
  893. #--------------------------------------------------------------------
  894.  
  895. # RSA:
  896.  
  897. # Key exchange occurs via encryption of a random value [chosen by the client] via the server public key. This requires the
  898. # server public key to be an RSA key, and the server certificate must utilize the 'keyAgreement' keyUsage extension).
  899.  
  900. # DH_RSA:
  901.  
  902. # Key exchange occurs via a static Diffie-Hellman key. Server Public Key must be a Diffie-Hellman key, of which must have
  903. # been issued by a CA that was using an RSA key signing key.
  904.  
  905. # DH_DSA:
  906. # Like DH_RSA, except that the CA used a DSA key in lieu of RSA.
  907.  
  908. # DHE_RSA:
  909.  
  910. # Key exchange occurs via an ephemeral Diffie-Hellman; the server dynamically generates & signs a DH public key, sending it to
  911. # the client. Server Public Key must be an RSA key, and it's certificate must utilize the digitalSignature keyUsage extension
  912.  
  913. # DHE_DSA:
  914. # Like DHE_RSA, except that the CA used a DSA key in lieu of RSA.
  915.  
  916.  
  917. #--------------------------------------------------------------------
  918. #####################################################################
  919. ##----- Elliptic-Curve Key Exchange Algorithms -----##
  920. #--------------------------------------------------------------------
  921.  
  922. # ECDH_ECDSA:
  923.  
  924. # Like DH_DSA, but with elliptic curves: the server public key must be an ECDH key, with a certificate issued by a CA
  925. # which utilized an ECDSA public key.
  926.  
  927. # ECDH_RSA:
  928. # Like ECDH_ECDSA, except that the CA used an RSA key
  929.  
  930. # ECDHE_ECDSA:
  931.  
  932. # The server sends a dynamically generated EC Diffie-Hellman key and signs it with its own ECDSA key. This is equivalent
  933. # to DHE_DSS, but with elliptic curves for both the Diffie-Hellman and signature.
  934.  
  935. # ECDHE_RSA:
  936.  
  937. # Like ECDHE_ECDSA, except that the server public key is an RSA key, utilized for signing the ephemeral elliptic-curve
  938. # Diffie-Hellman key.
  939.  
  940.  
  941. #--------------------------------------------------------------------
  942. #####################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement