Certificate management in Windows environment

Creating a certificate signing request

The following sections describe two ways in which this can be done in a Windows environment. Choose the one that suits you better and follow the steps below.

Using the Microsoft Management Console

1. First, prepare a location on your computer where you can later save the certificate request created in the next steps of these instructions. We recommend that you create a folder named "bapcrt" at "Computer" → "Local Disc (C :)". The example below shows the folder "bapcrt" created in an analogous location at "This PC" → "Windows (C :)".

images/7023dffaac10bb89b5291937207e273df00b26a20394ea26a7234434a588aeee.png

Picture 1. Creating the bapcrt folder


2. To open the user certificates manager, type "certificates" in the "Windows Start" bar to search for and choose "Manage user certificates".

images/726ce5039cad1021470c2b8f2689f625bc63e4e3ef2d28fc40caa168319b4475.png

Picture 2. Search in Windows Start bar


3. Right-click on "Personal" catalog to bring up the internal menu. From this menu, select "All Tasks" → "Advanced Operations" → "Create custom request".

images/55af51d8caf43d4cdcd5daf025d8d0ef72f7c13d60eda6957f621356eac8123b.png

Picture 3. Manage user certificates window


4. In opened "Certificates Enrollment" window click "Next".

images/f9f57a93afd56929659a67df30d0a2308a1af3289b65746fad8fb2e8d343e78c.png

Picture 4. Certificate Enrollment window


5. The next window will suggest a strategy for applying the certificate. In "Custom Request" select "Proceed without enrolment policy" and click "Next".

images/c4eecd9b4495dbc27d3fe74482700b2545fcd281ba8ca20b56827feb804c1bd3.png

Picture 5. Strategy selection window


6. In the next step expand "Template" dropdown meniu and select "(No template) Legacy key". Note the format "PKS # 10" and click "Next".

images/7abf6155801a791a92941151140b6b756fb1e07ccb47f61992c547d130a801ff.png

Picture 6. Template selection


7. In the certificate information window, expand the "Details" and click the "Properties" button.

images/58a9249d8eddf26e23df73507ed736e7bd8acd952d154c8459e3f61d12552f4e.png

Picture 7. Certificate Information Window


8. Select the "Subject" tab in an opened window.

images/cfce4e0db6dc452d26166118b9f79d488bb5ea3833104fd94ea87dadb80999f0.png

Picture 8. Subject tab


9. In the "Type" dropdown menu select "Common name".

images/0469a8c6ec68b42d43c0de28cb997cfeed45e340c809f57738873fc601a9d965.png

Picture 9. Subject name type selection


10. In the "Value" field enter your Name and Surname and click Add>.

images/78367f2adb6919ca1deb530a0bb747af415a2b0a6534e0a717466fe7fa30a45b.png

Picture 10. Subject name value


11. In the "Type" dropdown menu select "Given name", in "Value" field enter your name and click "Add>".

images/04aa49885a90158ce9c51d6a98a71f6ab0a07089660a4561544fe485966881b7.png

Picture 11. Filling in subject data


12. In "Type" dropdown menu select "Surname", in "Value" field enter your name and click "Add>".

images/7bb9a1922707836671630382cd5cc019ad67a9ac512f5dfa655e3960cc971788.png

Picture 12. Filling in subject data


13. When the "Subject name" values are filled in you can see them on the right pane with attributes CN, G, SN.

images/0addad3eb7ff0e313ec6da669fb0af478d4689c2ff57bef5d6e3e956664122c8.png

Picture 13. Subject name result


14. In the "Alternative name" section select "Email" from "Type" dropdown menu, enter your email address in "Value" field and click "Add>".

images/82512b38d8300f278557eb71462ec823b350a7c07416671e67ef1ad96280a014.png

Picture 14. Alternative name data


15. When the "Alternative name" value is filled in you can see email attribute on the right pane.

images/d49c1760cc01c9a3d8d9d292f183e04a6fb816eeecd66fba5d19f8a471370cc3.png

Picture 15. Alternative name result


16. Select "Private Key" tab section.

images/0395ff387eb5e35bab5c4662b7f523e66b5083b2b32ac4135544c389212e097a.png

Picture 16. Private key tab selection


17. Expand the "Key type" area and select the "Exchange" option.

images/ae081ef583766a7450d84913d695d3da5dff541d3729bf699ec27df9facfec17.png

Picture 17. Key type selection


18. Once you have selected the key type, you need to choose which algorithm is used to encrypt the data. To do this, expand the "Cryptographic Service Providers" section and make sure that only one option "Microsoft RSA SChannel Cryptographic Provider (Encryption)" is selected.

images/3da9cd4bf2025e24ce4c1c2571aace0474daaa426ef622b06a2f991fde270554.png

Picture 18. Encryption algorithm selection


19. Finally, you need to specify the key size by expanding the "Key options" section, selecting "2048" next to Key size and marking the "Make private key exportable" checkbox.

images/ca36a65e570d819d1e75331e4bbda9375177dfe71336729c4f4effa5ef54d792.png

Picture 19. Key size selection


20. After completing all the above steps, click on the "OK" button and you will be returned to the "Certificate Enrollment" wizard.

images/76ed9752d61006c5d3fe813ba99e9f7011f0224286a157abe0de31105477e75a.png

Picture 20. Certificate properties window closing


21. In "Certificate Enrollment" wizard click "Next" button.

images/39ec41050447451976edb1462a63582f8c6bb0ac5d192a5cc5ce060678732034.png

Picture 21. Certificate Enrollment wizard


22. The next step is to specify the disk location where you want to save the certificate request. To do this, click on the "Browse..." button.

images/b9cf75652b3d8ea3485bed91c0cb3b8306d25d552ff388d139576f43675754cb.png

Picture 22. Query save dialog


23. Select where you want to save the file.

It is recommended to store the file in the directory "bapcrt" created at the address given in step 1.

images/c2844d203ebd167b9403b1ff6643892134b412280bb4417c53e33cce2a8df554.png

Picture 23. File save dialog


24. It's important to save a file with a "csr" extension - to do this, add ".csr" ending to the file name and specify "All files (*. *)" option in the "Save as type" field. Click "Save" in the dialog box after completing all the steps.

images/fec74b37dee59d8e8b7d1c7654a34c980cb2966ecf56b8bb23b4ca9e5cc16f59.png

Picture 24. File save dialog


25. You will be returned to the "Certificate Enrolment" wizard. Click the "Finish" button. The CSR has been generated successfully and saved to the file you specified.

images/2e4d080e5851f9b61aae7b5affcf9310cd59e735b246e92e113e8c936f8af1f5.png

Picture 25. End of the wizard

Continue generating the certificate from the "Download and install the certificate" chapter.

Using Command Prompt

1. Create a "request.inf" file. The contents of the file are listed below.

Note

You can download the prepared "request.inf" file in the certificate generation window or on the login page.

images/f43a0053a77a47a181b7f867087296a4811d6a77cfa3b30cf892f390be006e11.png

Picture 26. Download of the request.inf file for authenticated BAP user


After downloading the file, please enter your full name (CN, G, SN) in the "Subject" line instead of "Name Surname" and your email address in the "_continue_" line.

;----------------- request.inf -----------------
[Version]
Signature="$Windows NT$"
[NewRequest]
Subject = "CN=Name Surname, G=Name, SN=Surname"
KeySpec = 1
KeyLength = 2048
Exportable = True
MachineKeySet = False
SMIME = False
PrivateKeyArchive = FALSE
UserProtected = FALSE
UseExistingKeySet = FALSE
ProviderName = "Microsoft RSA SChannel Cryptographic Provider"
ProviderType = 12
RequestType = PKCS10
KeyUsage = 0xa0
 
[Extensions]
2.5.29.17 = "{text}"
_continue_ = "email=email@example.com"
 
[EnhancedKeyUsageExtension]
OID=1.3.6.1.5.5.7.3.1
;-----------------------------------------------

Note

If you have not used the BAP system before and do not have the possibility to log in via the eGovernment Gateway, please see the section "Download and install the certificate".

Important

When saving the file "Encoding" must be selected "ANSI".

images/fb284c10dcc2b0add14a9208233cddfe927c81356445accf50c585e12f147531.png

Picture 27. Choosing a file encoding


2. Open the "cmd" command line. To do this, type "cmd" in the address bar of the current "bapcrt" folder and press the "Enter" key on your keyboard.

images/9998ef30f9fd057c6a6feb5871a80623f51f2fda5cef23cca9ba38133c743ef2.png

Picture 28. Opening CMD through the address bar


images/b9c7fd417ae2e6d3c4b910482adfec6805b2db767aad43f8720c4f61e2c16890.png

Picture 29. CMD line window


3. In the opened window, enter the following command:

C:\bapcrt> certreq -new request.inf request.csr

images/cde4fb70a139ac9061db7156beee81c0c4bb3e227a352c4e6c4dc94511061b05.png

Picture 30. Example of command entry


After successfully creating "request.csr", you will receive a response from the command line:

CertReq: Request Created

images/6eb149f9d3b9759f95e27d9369a4942a8a8579982b4b4cdb5070d7a00b3b4609.png

Picture 31. Response


images/66c94bc450a27086ad32c61db2e1707d0c389355b4f18b85aebd920541f920f3.png

Picture 32. Creating a file request.csr

Certificate download and installation

1. If you have not used the BAP system before and do not have the possibility to log in via the Electronic Government Gateway, please send the prepared "request.csr" file by email to the customs office when requested. You will receive a reply with the sertifikatas.crt attached file, which you should save in the "bapcrt" directory you created.

If you can log in to BAP using the authentication service provided by the Electronic Government Gateway, or if you have already used the BAP system in the past and you are able to login to it, click on the "+Add New" button in the "Profile" section, select the value "Certificate issued by the customs of the Republic of Lithuania - for connecting to customs portals and accessing customs system to system services." in the "Adding a new certificate" modal window, then click on the "Continue" button.

images/a89d087abb765b59fa1b23d2641f8e151ae83d0b22a3c8107c4181e566e33a27.png

Picture 33. "Customs of Lithuania for authentication" selection


Bookmark the file "request.csr" in the "Generate Certificate" window and click on the "Generate Certificate" button.

images/download/attachments/93118662/image-2023-9-15_10-36-19-version-1-modificationdate-1694763381000-api-v2.png
CSR file upload location

Picture 34. Uploading the CSR file


Download the "sertifikatas.crt" file by clicking the "Download" button in the pop-up window or in the certificate data table. Move the downloaded file to the "bapcrt" directory.

images/download/attachments/93118662/image-2023-9-15_10-39-1-version-1-modificationdate-1694763543000-api-v2.png
CRT file download

Picture 35. Downloading the CRT file

Note

The certificate can also be downloaded from the "Profile" certificate list by selecting the row of the certificate entry in the list and clicking the "Download" button. For more information see "Generating and adding a certificate after logging into the portal".

images/2e81351f9003bc130de6bc16e39907282413de719806a6a3edac869e8344ed99.png

Picture 36. Creating sertifikatas.crt file


2. Import the certificate into the user certificate cache. Right-click on the "sertifikatas.crt" file and select "Install Certificate" in the pop-up window that opens.

images/b2a5f2c91430279a075cdd81dc7cee9ba577895f50a7fad7b40f1f8b4dc2be73.png

Picture 37. Importing a certificate into the user certificate cache


images/c48c0af75f6eca4d4609d7b3c70d391a2f14b599a86bc985d54da550326735d4.png

Picture 38. Certificate Import Wizard: placement location selection


images/b196a103502d5a76f7f412443e0cf497b4c9cf6a074fb1b5c7d5fd04b53560fb.png

Picture 39. Certificate Import Wizard: specifying the location


images/7afc38bed179b003876e64a6a51a9680c3fab6eaa2aa2d16baa333b07478e2af.png

Picture 40. Certificate Import Wizard: Reviewing settings


images/dcbf7b1a66a20d18ba5c6e7bed76b8d487a550ab0ad4acc769274d5a110f591f.png

Picture 41. Certificate Import Wizard: notification of the successful completion of a certificate import

Preparing a certificate to run on another computer

1. To open the user certificates manager, type "certificates" in the "Windows Start" bar to search for and choose "Manage user certificates".

images/726ce5039cad1021470c2b8f2689f625bc63e4e3ef2d28fc40caa168319b4475.png

Picture 42. Search in the Windows Start bar


You should see the imported certificate in the "Certificates" directory.

images/47e8c1a4e6af86d0cfe67487f8b7aa2ed434f4563e2d74cd89a6351b880687f9.png

Picture 43. View the imported certificate


6. Check that the certificate has the appropriate private key. If you double left-click on the certificate, you should see "You have a private key that corresponds to this certificate".

images/d147fe77d5f2605e859cf2096e171959ca216c9a78a5955523f3981b99f627aa.png

Picture 44. Certificate private key verification


7. Export the certificate along with the private key to a file so you can use it on other computers and have a backup:

images/e88b22f6d747e36ba5d826efd092a07417ce0c2cd8b2f0c8fae85fe933971985.png

Picture 45. Certificate Export


8. In the "Certificate Export" wizard, click the "Next" button.

images/download/attachments/93118662/crt_install-8-version-1-modificationdate-1617618744000-api-v2-effects-border-simple-blur-border.png

Picture 46. Certificate Export Wizard


9. Mark "Personal Information Exchange - PKCS #12 (.PFX)", mark checkbox "Include all certificates in the certification path is possible" and "Enable certificate privacy" and click "Next".

images/download/attachments/93118662/crt_install-10-version-1-modificationdate-1617618744000-api-v2-effects-border-simple-blur-border.png

Picture 47. Certificate Export Wizard: Format selection


10. Select "Yes, export the private key" to export the private key together with the certificate and click "Next".

images/download/attachments/93118662/crt_install-9-version-1-modificationdate-1617618744000-api-v2-effects-border-simple-blur-border.png

Picture 48. Certificate Export Wizard: Exporting a private key


11. Create a password that will protect the private key of the certificate and click "Next".

images/download/attachments/93118662/crt_install-11-version-1-modificationdate-1617618744000-api-v2-effects-border-simple-blur-border.png

Picture 49. Certificate Export Wizard: Creating a password


12. Specify the export location and file name through "Browse..." function and click "Next".

images/394e753addde1c2df6a2bb2703502915f4eac475a8d94a16d09d10d887cd09c7.png

Picture 50. Certificate Export Wizard: Creating file name


13. Review the settings and complete the export operation and click "Finish".

images/4b7f706caf8f199a48061dc8e86fe36dd9efeb253a010bd8946ad66fc0c6f605.png

Picture 51. Certificate Export Wizard: Settings review


14. After completing this step you will be notified of successful completion of the export.

images/download/attachments/93118662/crt_install-14-version-1-modificationdate-1617618744000-api-v2-effects-border-simple-blur-border.png

Picture 52. Certificate Export Wizard: Notification of the successful completion of a certificate export


15. . The resulting "sertifikatas.pfx" file contains your certificate and its private key. You can easily import it to another computer.

images/034defb408cc2d7eb0a4d1e7c61fc809b99cb0f2c2aa85fff2f09735b19ef5ea.png

Picture 53. Display of the exported sertifikatas.pfx file