Generate A1 certificates for testing in the ICP standard-Brazil

Need to generate a fake digital certificate with the standard used by ICP-Brazil for testing systems with the following files:

1. certificate chain (Pro system identify certificate when imported into Browser)

2. client certificate (to authenticate to the System)

The certificate chain is required for the apache server to identify the clients that use the certificate chain AC.

I used the source code of the answer to this question and did not succeed, as it does not generate a certificate chain, the user's certificate appears to be valid: https://pt.stackoverflow.com/questions/358172/%c3%89-poss%c3%advel-criar-um-certificado-pfx-e-definir-um-oid-para-alguns-par%c3%a2metros#=

I tried to generate a certificate chain using the generated JKS file, it recognizes the client's certificate, but when trying to log in system with the generated certificate, it returns the following error:

an error occurred during a connection to seedbeds.local. The remote system does not recognize and does not trust the CA that issued your certificate. Error code: SSL_ERROR_UNKNOWN_CA_ALERT

Author: Vinicius Farias, 2019-05-07