> For the complete documentation index, see [llms.txt](https://docs.scepman.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scepman.com/pt/implementacao-do-scepman/intermediate-certificate.md).

# AC intermédia

Configure o SCEPman como uma autoridade de certificação subordinada.

{% hint style="warning" %}
Apenas na SCEPman Enterprise Edition
{% endhint %}

Utilize uma CA intermédia quando outra CA raiz continuar a ser a sua autoridade principal. A SCEPman cria a chave e o pedido de certificado no Azure Key Vault. A sua CA raiz assina o pedido.

### Antes de começar

Conclua estes pré-requisitos antes de criar o certificado:

* A sua conta de administrador pode criar pedidos de certificado e juntar certificados assinados no Key Vault da SCEPman.
* Um sistema com Azure CLI e PowerShell consegue aceder ao Key Vault.
* Conhece o assunto da CA intermédia e o nome do certificado necessários.

<details>

<summary>Conceder permissões de certificado do Key Vault</summary>

{% tabs %}
{% tab title="Azure RBAC" %}

1. No Key Vault, abra **Controlo de acesso (IAM)** → **Atribuições de funções**.
2. Adicione a função **Key Vault Certificate Officer** .
3. Atribua a função à conta de administrador que cria o CSR.

<figure><img src="https://3802289327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LoGejQeUQcw7lqnQ3WX%2Fuploads%2FZUqsPTRdUk5IhmZZlBVD%2Fimage.png?alt=media&amp;token=325c2296-4f6b-476d-b003-29cf3674556f" alt="Add a role assignment in the Key Vault"><figcaption><p>Adicione uma atribuição de função no Key Vault.</p></figcaption></figure>

<figure><img src="https://3802289327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LoGejQeUQcw7lqnQ3WX%2Fuploads%2FptcaAY0strUu3qIgkTdc%2Fimage.png?alt=media&amp;token=6bf4adc2-da77-4ece-ba68-09c61fc6905e" alt="Select the Key Vault Certificate Officer role"><figcaption><p>Selecione a função Key Vault Certificate Officer.</p></figcaption></figure>
{% endtab %}

{% tab title="Políticas de acesso do cofre" %}

1. No Key Vault, abra **Políticas de acesso** e selecione **Criar**.
2. Selecione o modelo **Gestão de certificados** .
3. Atribua a política à conta de administrador que cria o CSR.

<figure><img src="https://3802289327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LoGejQeUQcw7lqnQ3WX%2Fuploads%2FD2mWeiZ7YnQuRN0rdypW%2F2023-06-14%2016_20_43-IntermediateCert.png?alt=media&amp;token=da6b385e-8902-4b53-8a9f-25f3573d6532" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3802289327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LoGejQeUQcw7lqnQ3WX%2Fuploads%2F37QHfqcQRHNboM4yQkTb%2F2023-06-14%2016_23_37-IntermediateCert.png?alt=media&amp;token=3cc22a95-8f13-4487-b270-083efa2779bd" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3802289327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LoGejQeUQcw7lqnQ3WX%2Fuploads%2FIj3S2D7wkNquLnBJSUQe%2F2023-06-14%2017_06_33-.png?alt=media&amp;token=195c03cb-a120-434b-8aa1-c44d4b2d26f6" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

</details>

<details>

<summary>Permitir acesso de rede ao Key Vault</summary>

Se o seu Key Vault utilizar [Endpoints privados](https://docs.scepman.com/pt/configuracao-do-azure/private-endpoints.md), permita o acesso à estação de trabalho ou ao ambiente Cloud Shell utilizado abaixo. Sem este acesso, o módulo não consegue criar o CSR nem juntar o certificado.

No Key Vault, abra **Definições** → **Rede**. Permita a rede virtual ou o endereço IP do cliente relevante. Também é compatível com o [Azure Cloud Shell](https://learn.microsoft.com/en-us/azure/cloud-shell/vnet/overview) ligado a uma VNet. Remova as exceções de rede temporárias depois de juntar o certificado.

</details>

### Criar a CA intermédia

{% stepper %}
{% step %}

#### Configurar as definições de certificado da SCEPman

No App Service da SCEPman, abra **Variáveis de ambiente**. Em **Definições da aplicação**, atualize:

* `AppConfig:KeyVaultConfig:RootCertificateConfig:CertificateName`: o nome do certificado no Key Vault. Utilize apenas letras, números e hífenes.
* `AppConfig:KeyVaultConfig:RootCertificateConfig:Subject`: altere apenas o `CN` para o mesmo nome comum.

Selecione **Aplicar** e confirme as alterações. **Reinicie** o App Service. Em seguida, abra o URL do SCEPman.

<figure><img src="https://3802289327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LoGejQeUQcw7lqnQ3WX%2Fuploads%2FvO2YgKtltBesm2Eme7ix%2Fimage.png?alt=media&amp;token=9ec3f21e-b6eb-47c5-8e10-3e2cbe519669" alt="SCEPman App Service certificate settings"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Criar o pedido de certificado

Utilize a versão 1.9 ou posterior do módulo SCEPman PowerShell. [Azure Cloud Shell](https://learn.microsoft.com/en-us/azure/cloud-shell/overview) é recomendado, pois inclui o Azure CLI. Caso contrário, instale o [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli).

```powershell
Install-Module -Name SCEPman -Scope CurrentUser -Force
```

Defina a sua organização:

```powershell
Reset-IntermediateCaPolicy -Organization "My Organization"
```

Defina o assunto com o valor configurado no App Service. Também pode ajustar outras definições de política antes de a guardar.

{% code lineNumbers="true" %}

```powershell
$policy = Get-IntermediateCaPolicy
$policy.policy.x509_props.subject = "CN=YOUR_CN_FROM_ABOVE,OU=YOUR_TENANT_ID,O=YOUR_ORGANIZATION"
# change some additional settings of $policy
Set-IntermediateCaPolicy -Policy $policy
```

{% endcode %}

Criar o CSR:

```powershell
New-IntermediateCA -SCEPmanAppServiceName "app-scepman-example" -SearchAllSubscriptions 6>&1
```

O comando apresenta o CSR da sua CA raiz.
{% endstep %}

{% step %}

#### Emitir o certificado da CA intermédia

Obtenha o certificado emitido da sua CA raiz. Guarde-o como um ficheiro `.cer` codificado em Base64.

<details>

<summary>CA raiz do SCEPman: envie o CSR através do Certificate Master</summary>

Abra [Pedido de assinatura de certificado (CSR)](https://docs.scepman.com/pt/gestao-de-certificados/certificate-master/certificate-signing-request-csr.md). Cole o CSR codificado em PEM ou carregue o ficheiro CSR para emitir o certificado da CA intermédia. Altere **Formato do ficheiro de transferência** para **PEM** antes de transferir o certificado.

</details>

<details>

<summary>CA raiz empresarial do ADCS: adicionar Key Encipherment</summary>

Isto aplica-se apenas às CAs raiz empresariais do ADCS integradas no AD. O certificado tem de incluir `CRLSign`, `DigitalSignature`, `KeyEncipherment`, e `KeyCertSign`. O modelo predefinido **Autoridade de Certificação Subordinada** não inclui `KeyEncipherment`. As CAs raiz autónomas e offline utilizam os usos de chave do CSR.

1. Peça e emita um certificado SubCA. Pode duplicar o modelo SubCA.
2. Na CA raiz, exporte o certificado como X.509 codificado em Base64, por exemplo `C:\temp\SubCA.cer`.
3. Crie `C:\temp\extfile.txt`:

```
[Extensions]
2.5.29.15=AwIBpg==
Critical=2.5.29.15
```

4. Executar:

```powershell
certutil -sign "C:\temp\SubCA.cer" "C:\temp\SubCAwithKeyEncipher.cer" @C:\temp\extfile.txt
```

O certificado de saída tem a utilização de chave `0xA6`. A assinatura é alterada, mas o número de série não. A revogação do certificado ADCS original também revoga o certificado novamente assinado. Opcionalmente, elimine a entrada antiga com `certutil -deleterow` e importe o novo certificado com `certutil -importcert`.

</details>
{% endstep %}

{% step %}

#### Intercalar o certificado assinado

No Azure Key Vault, abra o certificado e selecione **Operação do certificado** → **Intercalar pedido assinado**. Carregue o certificado emitido. O certificado aparece em **Concluído** quando a intercalação é bem-sucedida.

![Opções de operação de certificados no Azure Key Vault](https://3802289327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LoGejQeUQcw7lqnQ3WX%2Fuploads%2Fgit-blob-9b845d790796a34cb0e9296434373a502ddfee92%2Fscreenshot-2020-10-19-at-16.01.18%20\(1\)%20\(2\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(3\).png?alt=media)

{% hint style="warning" %}
O certificado tem de utilizar a codificação PEM ou Base64. A codificação binária DER provoca um erro `x5c has invalid value` .
{% endhint %}
{% endstep %}

{% step %}

#### Verificar a AC

Abra a página de estado do SCEPman. Confirme que **Adequação da AC** não indica requisitos em falta. Transfira o certificado da AC intermédia para implementação através do seu MDM.

Se o SCEPman indicar que `Key Encipherment` está em falta, corrija o certificado emitido e volte a intercalá-lo.
{% endstep %}
{% endstepper %}

### Perfis SCEP do Intune

* **Android:** referencie a AC raiz.
* **Windows:** referencie a AC intermédia.
* **iOS e macOS:** não existe uma recomendação conclusiva.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.scepman.com/pt/implementacao-do-scepman/intermediate-certificate.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
