# Yêu cầu bảo mật

### API Key <a href="#api-key" id="api-key"></a>

Tất cả các request từ phía đối tác gọi sang hệ thống của Gotadi phải chứa các Headers bên dưới để phục vụ các nghiệp vụ về bảo mật và thống kê số liệu của Gotadi:

* apikey: \<api\_key>
* x-ibe-req-name: \<access\_code>

Lưu ý

Giá trị \<api\_key> và \<access\_code> do Gotadi cung cấp cho Đối tác.

***

### Chữ ký điện tử (Signature) <a href="#chu-ky-ien-tu-signature" id="chu-ky-ien-tu-signature"></a>

Một số API quan trọng được yêu cầu đính kèm chữ ký điện tử vào request và response để xác thực.

<details>

<summary>Khởi tạo chữ ký chữ ký điện tử</summary>

<img src="https://developer.gotadi.com/img/3.png" alt="" data-size="original">

Bên gửi áp dụng thuật toán **RSA-SHA256** kết hợp với **Private key của chính mình** để ký chữ ký điện tử trên signature data.

Lưu ý

Schema để thành lập signature data sẽ được mô tả cụ thể ở từng API.

Java example code

```
public static String signRSA(String signatureData, String xmlPrivateKey) throws Exception {
    PrivateKey privateKey = getPrivateKeyFromXML(xmlPrivateKey);
    Signature instance = Signature.getInstance("SHA256withRSA");
    instance.initSign(privateKey);
    instance.update(signatureData.getBytes("UTF-8"));
    byte[] signature = instance.sign();
    return Base64.encodeBase64String(signature);
}
```

</details>

<details>

<summary>Xác thực chữ ký điện tử</summary>

<img src="https://developer.gotadi.com/img/7.png" alt="" data-size="original">

Bên nhận sử dụng Thuật toán **RSA-SHA256 và Public key của bên gửi** để xác thực signature được bên gửi tạo ra.

Java example code

```
public static boolean verifyRSA(String signedData, String signature, String xmlPublicKey) throws Exception {
    PublicKey publicKey = getPublicKeyFromXML(xmlPublicKey);
    Signature instance = Signature.getInstance("SHA256withRSA");
    instance.initVerify(publicKey);
    instance.update(signedData.getBytes("UTF-8"));
    return instance.verify(Base64.decodeBase64(signature));
}
```

</details>

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.gotadi.com/vietnamese/doi-tac-corporate-agent-ca/yeu-cau-bao-mat.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
