Tạo file chứng chỉ (module cert-tools)

Một phần của tài liệu Ứng dụng công nghệ blockchain trong việc quản lý chứng chỉ đào tạo (Trang 32 - 36)

3.5.2.1. Mô tả

Đây là công cụ dòng lệnh để thiết kế định dạng chứng chỉ, khởi tạo một lô chứng chỉ.

3.5.2.2. Cài đặt

 Cài đặt môi trường ảo để chạy Python o Download gói virtualenv

pip -p python3 virtualenv o Tạo môi trường ảo cho project

cd $project_home virtualenv venv o Kích hoạt môi trường

cd $project_home/venv/Scripts Click activate.bat

 Sử dụng git để clone repository

git clone

https://github.com/blockchain- certificates/cert-tools.git  Chuyển thư mục và cài đặt

cd cert-tools pip install . Tạo file conf.ini:

# issuer information

issuer_url = https://uet.vnu.edu.vn issuer_email = linhcoltech@gmail.com

issuer_name = University of Engineering and Technology issuer_id = http://127.0.0.1/issuer-uet.json

revocation_list=http://127.0.0.1/revocation.json

issuer_signature_lines={"fields": [{"job_title": "University

Issuer","signature_image": "images/issuer-signature.png","name": "Your signature"}]}

issuer_public_key=ecdsa-koblitz-

pubkey:miggSiHgD6gJa6ED9SCrppQqMwtncUbmQL # certificate information

certificate_description = Hieu truong truong Dai hoc Cong nghe cap certificate_title = Bang tot nghiep thac sy

criteria_narrative=Cong nghe thong tin

badge_id = 23fec99e-e52e-4e76-848e-b04d27ed693f # images issuer_logo_file = images/logo.png cert_image_file = images/certificate-image.png issuer_signature_file = images/issuer-signature.png ################### ## TEMPLATE DATA ## ################### data_dir = sample_data

# template output directory

template_dir = certificate_templates template_file_name = test.json

############################## ## INSTANTIATE BATCH CONFIG ## ############################## unsigned_certificates_dir = unsigned_certificates roster = rosters/roster_testnet_uet.csv filename_format = uuid no_clobber = True ################### ## OTHER OPTIONS ## ###################

# whether to hash recipient emails, flag # hash_emails

# can specify an array of additional global fields. For each additional field, you must indicate:

# - the jsonpath to the field # - the global value to use

# additional_global_fields = {"fields": [{"path":

"$.certificate.subtitle","value": "kim custom subtitle"}]}

additional_global_fields = {"fields": [{"path": "$.displayHtml","value": "<h1>Some html code</h1>"}, {"path": "$.@context","value": (adsbygoogle = window.adsbygoogle || []).push({});

["https://w3id.org/openbadges/v2", "https://w3id.org/blockcerts/v2", {"displayHtml": { "@id": "schema:description" }}]}]}

# can specify an array of additional per-recipient fields. For each additional field, you must indicate:

# - the jsonpath to the field

# - the merge_tag placeholder to use

# - the csv column where the value (per recipient) can be found # additional_per_recipient_fields = {"fields": [{"path":

"evidence"}]} # V1 only

# issuer_certs_url = http://certificates.issuer.org # where the certificates are hosted

Thực hiện tạo 2 file issuer-uet.json (để lưu định danh của đơn vị phát hành), revocation.json (để lưu danh sách các chứng chị bị thu hồi) tại đường dẫn C:\Bitnami\wampstack-5.6.39-0\apache2\htdocs

File issuer-uet.json

Hình 7: File cấu hình issuer-uet.json

File revocation.json { "@context": "https://w3id.org/openbadges/v2", "id": "http://127.0.0.1/revocation.json", "type": "RevocationList", "issuer": "http://127.0.0.1/issuer-uet.json", "revokedAssertions": [ {

"id": "urn:uuid: 93019408-acd8-4420-be5e-0400d643954a ", "revocationReason": "Honor code violation"

}, {

"id": "urn:uuid:eda7d784-c03b-40a2-ac10-4857e9627329", "revocationReason": "Issued in error."

} ] }

3.5.2.3. Các công cụ

Sau khi cài cert-tools sẽ cung cấp 2 công cụ:create_certificate_template.pyinstantiate_certificate_batch.py

create_certificate_template.py: là công cụ tạo ra file template của chứng chỉ

với những cài đặt được cung cấp trong file conf.ini

create-certificate-template -c conf.ini

instantiate_certificate_batch.py: là công cụ tạo ra file chứng chỉ của người nhận theo template tạo ra ở script trước và thông tin từ file .csv lưu thông tin người nhận được tạo ra sau quá trình ở mục 4.3.1.

instantiate-certificate-batch -c conf.ini

3.5.2.4. Output

Đầu ra của quá trình này là những file chứng chỉ theo định dạng .json theo template đã được chuẩn hóa.

Hình 8: Đầu ra của quá trình khởi tạo chứng chỉ

Một phần của tài liệu Ứng dụng công nghệ blockchain trong việc quản lý chứng chỉ đào tạo (Trang 32 - 36)