Giter Club home page Giter Club logo

alfresco-ssl-generator's Introduction

Welcome to Alfresco SSL Generator

This is a script automation for the generation of the required keystores, truststores and browser certificates for Alfresco configuration using Mutual TLS Authentication between Repository and SOLR. These same files can be obtained manually by using any other cryptographic tools.

This project is not officially supported by Alfresco, as it provides just a sample to build your own security configuration for Alfresco. However, anyone can improve this tool by providing pull requests or by cloning the project and changing it accordingly to suit particular needs.

As HTTPs invocations happen between different Alfresco services, following relationships must be satisfied:

  • Repository is client of SOLR and Transform Services

    • Repository key must be generated and must be included in Repository keystore
    • Root CA certificate must be included in Repository truststore
  • SOLR is client of Repository and SOLR

    • SOLR key must be generated and must be included in SOLR keystore
    • Root CA certificate must be included in SOLR truststore
  • Zeppelin is client of Repository (Zeppelin is a product only available for Insight Engine Enterprise)

    • Zeppelin key must be generated and must be included in Zeppelin keystore
    • Root CA certificate must be included in Zeppelin truststore
    • Note that this script tool uses the same key certificates for SOLR and Zeppelin, as both are clients of the Repository
  • When accessing SOLR from a browser, the browser is client of SOLR

    • Browser key must be installed on the browser in order to access SOLR Web Console
  • Transform Services (Transform Router, T-Engines, Transform Aspose, AI Renditions, Shared File Store)

    • Transform Service key must be generated and must be included in Transform Service keystore for every Transform Service present
    • Root CA certificate must be included in Transform Service truststore for every Transform Service present

Additionally, to support Alfresco encryption feature, a metadata cyphering key is generated and included on a keystore to be used by the Repository.

Usage

Certificates generation script run.sh is based in OpenSSL and Java keytool programs, and it can be used in different scenarios:

  • Bash Shell Script Standalone, as a local bash script from Linux operative systems. The shell script and the OpenSSL configuration file are available in ssl-tool folder.
  • Windows Batch Script Standalone, as a local batch script from Windows operative systems. The batch script and the OpenSSL configuration file are available in ssl-tool-win folder.
  • Docker Standalone, as a local container generating keystores folder from environment variable values. Available from Linux, Windows and Mac OS X.
  • Docker Compose, as a Docker service creating keystores folder from environment variable values. Available from Linux, Windows and Mac OS X.

New certificates generation scripts run_ca.sh, run_encryption.sh and run_additional.sh have been created to respond to the need of adding a varying number of additional services to mTLS. They also provide more granularity and control over passwords and other settings. They are currently unavailable for use in Docker Standalone and Docker Compose

Requisites

Running the generation script requires having OpenSSL and Java keytool programs installed and available in the system path.

OpenSSL

OpenSSL is a cryptographic software to generate certification authorities, private keys and certificates (including usage policies).

Many distributions of Linux include OpenSSL as a package, so you can install it as any other program.

Ubuntu

$ sudo apt-get install openssl

CentOS

$ yum -y install openssl openssl-devel

For Mac OS X, some package manager like Homebrew can be used:

$ brew install openssl

When using Windows, binaries distribution from OpenSSL web page can be used:

https://wiki.openssl.org/index.php/Binaries

Remember to add openssl program to system path.

Keytool

Keytool is a standard Java program to build keystores and truststores.

The keytool utility is included with the JRE.

Both Oracle JRE 11 and OpenJDK JRE 11 can be used, just follow the installation instructions for your operative system.

Remember to add keytool program to system path.

Parameters

Both command line scripts and Docker Image resources can be parametrised by using external parameter values. Different options are described in the table below.

Script run parameter name Docker Parameter name Description Values
-alfrescoversion ALFRESCO_VERSION Type of Alfresco Version enterprise or community
-keysize KEY_SIZE RSA key length 2048, 4096..., by default 2048
-keystoretype KEYSTORE_TYPE Type of the keystores (containing private keys) PKCS12, JKS, JCEKS
-truststoretype TRUSTSTORE_TYPE Type of the truststores (containing public keys) JKS, JCEKS
-keystorepass KEYSTORE_PASS Password for the keystores Any string
-truststorepass TRUSTSTORE_PASS Password for the truststores Any string
-encstorepass ENC_STORE_PASS Password for the encryption keystore Any string
-encmetadatapass ENC_METADATA_PASS Password for the encryption metadata Any string
-cacertdname CA_CERT_DNAME Distinguished Name of the CA certificate, starting with slash and quoted "/C=GB/ST=UK/L=Maidenhead/O=Alfresco Software Ltd./OU=Unknown/CN=Custom Alfresco CA"
-repocertdname REPO_CERT_DNAME Distinguished Name of the Repository certificate, starting with slash and quoted "/C=GB/ST=UK/L=Maidenhead/O=Alfresco Software Ltd./OU=Unknown/CN=Custom Alfresco Repository"
-solrcertdname SOLR_CERT_DNAME Distinguished Name of the SOLR certificate, starting with slash and quoted "/C=GB/ST=UK/L=Maidenhead/O=Alfresco Software Ltd./OU=Unknown/CN=Custom Alfresco Repository Client"
-browsercertdname BROWSER_CERT_DNAME Distinguished Name of the BROWSER certificate, starting with slash and quoted "/C=GB/ST=UK/L=Maidenhead/O=Alfresco Software Ltd./OU=Unknown/CN=Custom Browser Client"
-caservername CA_SERVER_NAME DNS Name for CA Server Any string, localhost by default
-alfrescoservername ALFRESCO_SERVER_NAME DNS Name for Alfresco Server Any string, localhost by default
-solrservername SOLR_SERVER_NAME DNS Name for SOLR Server Any string, localhost by default
-alfrescoformat ALFRESCO_FORMAT Default format for certificates, truststores and keystores classic or current (only supported from ACS 7.0)
-cavalidityduration CA_VALIDITY_DURATION Validity duration of the Root CA in days Positive integer, 7300 by default
Script run_ca parameter name Description Values
-keysize RSA key length 2048, 4096...
-keystorepass Password for the keystores Any string between 6 to 1023 characters, if not provided a prompt will be displayed
-certdname Distinguished Name of the CA certificate, starting with slash and quoted "/C=GB/ST=UK/L=Maidenhead/O=Alfresco Software Ltd./OU=Unknown/CN=Custom Alfresco CA"
-servername DNS Name for CA Server Any string, localhost by default
-validityduration Validity duration of the Root CA in days Positive integer, 365 by default
Script run_encryption parameter name Description Values
-servicename Service name, will be used for keystore file name and key alias Any string, by default encryption
-subfoldername Name of a subfolder where the encryption keystore will be placed Any string, by default the same as value of servicename parameter
-encstorepass Password for the encryption keystore Any string between 6 to 1023 characters, if not provided a prompt will be displayed
-encmetadatapass Password for the encryption metadata Any string between 6 to 1023 characters, if not provided a prompt will be displayed
-alfrescoformat Default format for certificates, truststores and keystores classic or current (only supported from ACS 7.0)
Script run_additional parameter name Description Values
-servicename Service name, will be used for keystore file name and key alias Any string, by default service
-subfoldername Name of a subfolder where the service keystore will be placed Any string, by default the same as value of servicename parameter
-alias Key alias Any string, by default the same as value of servicename parameter
-role Role to be fulfilled by the keystore key, different roles correspond to dedicated settings in openssl.cnf file client, server, both, by default both
-rootcapass Password set for Root CA, is required for signing the additional keystores Any string. Lack of this parameter will result with an exception.
-keysize RSA key length 2048, 4096..., by default 2048
-keystoretype Type of the keystores (containing private keys) PKCS12, JKS, JCEKS, by default JCEKS
-keystorepass Password for the keystores Any string between 6 to 1023 characters, if not provided a prompt will be displayed
-notruststore Flag for blocking truststore generation N/A, providing the flag turns off truststore generation
-truststoretype Type of the truststores (containing public keys) JKS, JCEKS, by default JCEKS
-truststorepass Password for the truststores Any string between 6 to 1023 characters, if not provided a prompt will be displayed
-certdname Distinguished Name of the CA certificate, starting with slash and quoted "/C=GB/ST=UK/L=Maidenhead/O=Alfresco Software Ltd./OU=Unknown/CN=Custom Service"
-servername DNS Name for CA Server Any string, localhost by default
-alfrescoformat Default format for certificates, truststores and keystores classic or current (only supported from ACS 7.0)

When using Alfresco on an internal network, each server should have a different name. This names can be configured on the parameters named as *servername. In order to avoid browser complains about certificates, it's recommended to include the name of the server as Alternative Name in the certificate. This should be at least required for SOLR Web Console, as this application is only available in https when using this configuration. If you are working under a Web Proxy, use the name of this proxy for the *servername parameters. Scripts have been updated to handle multiple Service Alternative Names. To provide multiple of them seperate them with ,, example: -servername localhost,additionalSAN. For Windows variant the value needs to be enclosed in double quotes.

Bash Shell Script Standalone (Linux, Mac OS X)

When working on a Linux machine, shell scripts can be used directly from command line. It's required to have OpenSSL and keytool programs available in the environment. It is recommended to use the latest versions of these programs when possible.

The scripts parameters can be set through command line.

For instance, the following command will produce keystores folder in a host folder named keystores using RSA key length of 2048 bits for Alfresco Enterprise.

$ cd ssl-tool

$ ./run.sh -keysize 2048 -alfrescoversion enterprise -alfrescoformat classic

$ tree keystores/
keystores/
├── alfresco
│   ├── keystore
│   ├── keystore-passwords.properties
│   ├── ssl-keystore-passwords.properties
│   ├── ssl-truststore-passwords.properties
│   ├── ssl.keystore
│   └── ssl.truststore
├── client
│   └── browser.p12
├── solr
│   ├── ssl-keystore-passwords.properties
│   ├── ssl-truststore-passwords.properties
│   ├── ssl.repo.client.keystore
│   └── ssl.repo.client.truststore
└── zeppelin
    ├── ssl.repo.client.keystore
    └── ssl.repo.client.truststore

When using custom DNames for certificates, values must be set in quotes.

$ ./run.sh -cacertdname "/C=GB/ST=UK/L=Maidenhead/O=Alfresco/OU=Unknown/CN=Linux Alfresco CA" \
-repocertdname "/C=GB/ST=UK/L=Maidenhead/O=Alfresco/OU=Unknown/CN=Repo" \
-solrcertdname "/C=GB/ST=UK/L=Maidenhead/O=Alfresco/OU=Unknown/CN=Solr" \
-browsercertdname "/C=GB/ST=UK/L=Maidenhead/O=Alfresco/OU=Unknown/CN=Browser"

Note that when keystores folder is not empty, the program exists without producing any keystore or truststore.

When using current Alfresco format (default option), instead of classic, following output is generated.

$ cd ssl-tool

$ ./run.sh -keysize 2048 -alfrescoversion enterprise

$ tree keystores/
keystores/
├── alfresco
│   ├── keystore
│   ├── ssl.keystore
│   └── ssl.truststore
├── client
│   └── browser.p12
├── solr
│   ├── ssl-repo-client.keystore
│   └── ssl-repo-client.truststore
└── zeppelin
    ├── ssl-repo-client.keystore
    └── ssl-repo-client.truststore

For the current format all the passwords are passed to the applications using Java Environment Variables, so the password files are not required any more.

If you desire more control and granularity, or need to add other services into the mTLS mix, then you might want to consider using run_ca.sh, run_encryption.sh and run_additional.sh in place of run.sh script or only run_additional.sh as an addition. run_ca.sh - script responsible for preparing folders (ca, certificates, keystores) and generating the Root CA, run_encryption.sh - script responsible for generating the metadata encryption keystore run_additional.sh - script using the previously generated CA (with run.sh or run_ca.sh script) to generate additional sets of keystore and truststore.

Samples of using these scripts and how they replace the run.sh functionality or add on to it can be found in ssl-tool\samples folder of this project. Keep in mind that some locations of generated scripts or names of keystores might differ between the samples of new approach (run_ca.sh + run_encryption.sh + run_additional.sh) and legacy approach (run.sh + run_additional.sh).

If you'd like to restrict the certificates provided to a truststore, to pick and choose between which ones should be added to which service, you can do that by adding to the command of run_additional.sh script the -notruststore flag. This flag causes run_additional.sh script to not generate a truststore on its own. Afterwards you can write your own instructions to generate a truststore by picking certificates from the certificates folder that would end up in it after running the scripts. Sample command that would create a truststore for Solr that contains only the Repository certificate: keytool -importcert -noprompt -alias alfresco -file certificates/alfresco.cer -keystore keystores/solr/solr.truststore -storetype JCEKS -storepass password

You can add more certificates this way.

Batch Script Standalone (Windows)

When working on a Windows machine, shell scripts can be used directly from command line. It's required to have OpenSSL and keytool programs available in the PATH. It is recommended to use the latest versions of these programs when possible.

The parameters described above, can be used from command line.

For instance, the following command will produce keystores folder in a host folder named keystores using RSA key length of 2048 bits for Alfresco Community.

C:\> cd ssl-tool-win

C:\> run.cmd -keysize 2048 -alfrescoversion community -alfrescoformat classic

C:\> tree /F keystores
├───alfresco
│       keystore
│       keystore-passwords.properties
│       ssl-keystore-passwords.properties
│       ssl-truststore-passwords.properties
│       ssl.keystore
│       ssl.truststore
│
├───client
│       browser.p12
│
└───solr
        ssl-keystore-passwords.properties
        ssl-truststore-passwords.properties
        ssl.repo.client.keystore
        ssl.repo.client.truststore

When using custom DNames for certificates, values must be set in quotes.

C:\> run.cmd -cacertdname "/C=GB/ST=UK/L=Maidenhead/O=Alfresco/OU=Unknown/CN=Windows Alfresco CA" ^
-repocertdname "/C=GB/ST=UK/L=Maidenhead/O=Alfresco/OU=Unknown/CN=Repo" ^
-solrcertdname "/C=GB/ST=UK/L=Maidenhead/O=Alfresco/OU=Unknown/CN=Solr" ^
-browsercertdname "/C=GB/ST=UK/L=Maidenhead/O=Alfresco/OU=Unknown/CN=Browser"

Note that when keystores folder is not empty, the program exists without producing any keystore or truststore.

When using current Alfresco format (default option), instead of classic, following output is generated.

C:\> cd ssl-tool-win

C:\> run.cmd -keysize 2048 -alfrescoversion community

C:\> tree /F keystores
├───alfresco
│       keystore
│       ssl.keystore
│       ssl.truststore
│
├───client
│       browser.p12
│
└───solr
        ssl.repo.client.keystore
        ssl.repo.client.truststore

For the current format all the passwords are passed to the applications using Java Environment Variables, so the password files are not required any more.

If you desire more control and granularity, or need to add other services into the mTLS mix, then you might want to consider using run_ca.cmd, run_encryption.cmd and run_additional.cmd in place of run.cmd script or only run_additional.cmd as an addition. run_ca.cmd - script responsible for preparing folders (ca, certificates, keystores) and generating the Root CA, run_encryption.cmd - script responsible for generating the metadata encryption keystore run_additional.cmd - script using the previously generated CA (with run.cmd or run_ca.cmd script) to generate additional sets of keystore and truststore.

Samples of using these scripts and how they replace the run.cmd functionality or add on to it can be found in ssl-tool-win\samples folder of this project. Keep in mind that some locations of generated scripts or names of keystores might differ between the samples of new approach (run_ca.cmd + run_encryption.cmd + run_additional.cmd) and legacy approach (run.cmd + run_additional.cmd).

If you'd like to restrict the certificates provided to a truststore, to pick and choose between which ones should be added to which service, you can do that by adding to the command of run_additional.cmd script the -notruststore flag. This flag causes run_additional.cmd script to not generate a truststore on its own. Afterwards you can write your own instructions to generate a truststore by picking certificates from the certificates folder that would end up in it after running the scripts. Sample command that would create a truststore for Solr that contains only the Repository certificate: keytool -importcert -noprompt -alias alfresco -file certificates/alfresco.cer -keystore keystores/solr/solr.truststore -storetype JCEKS -storepass password

You can add more certificates this way.

Installing Browser certificate

In order to access to SOLR Web Console, available by default at https://localhost:8983/solr, browser certificate must be installed in your machine.

For Windows systems, client\browser.p12 file must be imported as new private certificate to Windows Certificates application.

For Mac OS X systems, client/browser.p12 file must be imported to Keychain Access application.

Also setting the right options in these application to trust in this certificate is required.

Once the certificate is installed, the following message should be showed by your browser when accessing to Solr Web Console:

Your connection is not private
Attackers might be trying to steal your information from localhost (for example, passwords, messages or credit cards). Learn more
NET::ERR_CERT_AUTHORITY_INVALID

As the certificate has been generated for localhost, this warning is expected. Just click on Advanced >> Proceed and use your browser certificate to access Solr Web Console.

Docker Standalone

Building the Docker Image

This image depends on the alfresco-docker-base-java image, which is also available (privately) on Quay and (publicly) on Docker Hub.

To build this image, run the following script:

docker build -t alfresco/alfresco-base-ssl .

The image can be used via docker run to create stores and certificates, using a host mounted folder to obtain these results.

Volumes

Following folders are available to be mounted on volumes:

  • /keystores folder contains the keystores and truststores generated for alfresco, solr and zeppelin services
  • /ca folder contains internal information (CRL, CA key...) used by the CA created with OpenSSL
  • /certificates folder contains raw certificates used to build the keystores and the truststores

To obtain the required folder for Alfresco services, it's only required to mount keystores folder. CA and certificates folder can be also mounted, but those files are not used for Alfresco configuration.

$ docker run -v $PWD/keystores:/keystores alfresco/alfresco-base-ssl

$ tree keystores
keystores
├── alfresco
│   ├── keystore
│   ├── ssl.keystore
│   └── ssl.truststore
├── client
│   └── browser.p12
├── solr
│   ├── ssl-repo-client.keystore
│   └── ssl-repo-client.truststore
└── zeppelin
    ├── ssl-repo-client.keystore
    └── ssl-repo-client.truststore

Parameters

Docker Container can be started using some of the parameters defined above.

For instance, the following command will produce keystores folder in a host folder named keystores using RSA key length of 2048 bits for Alfresco Enterprise.

$ docker run -v $PWD/keystores:/keystores -e KEY_SIZE=2048 -e ALFRESCO_VERSION=enterprise alfresco/alfresco-base-ssl

Note that when keystores folder is not empty, the program exists without producing any keystore or truststore.

Docker Compose

This Docker Image can be used as a Docker Compose service, accepting the same parameters for environment variables described before.

For instance, the following command will produce keystores folder in a host folder named keystores using RSA key length of 2048 bits for Alfresco Enterprise.

ssl:
    image: alfresco/ssl-base
    environment:
        ALFRESCO_VERSION: enterprise
        KEY_SIZE: 2048
    volumes:
        - ./keystores:/keystores

Sample configurations for Alfresco Enterprise and Alfresco Community have been provided at docker-compose folder.

Known issues

"SEC_ERROR_REUSED_ISSUER_AND_SERIAL" error when accessing SOLR Web Console in Firefox*

If you are using Alfresco SSL Generator for testing or developing and you issued the same CA Certificate more than one time, Firefox will complain when trying to access to SOLR Web Console (https://localhost:8983/solr by default).

This problem is described at Bugzilla:

https://bugzilla.mozilla.org/show_bug.cgi?id=435013

Apply any of the workarounds provided (as removing cert8.db or cert9.db file from your Firefox profile folder) in order to fix this problem.

Using Custom Certificates

When using certificates from external CAs, not the one provided by this project, building the keystores and truststores for Repository and SOLR is required. keytool or any other tool can be used in order to build these stores. Details on the content of every related file is available in Alfresco MTLS Configuration Deep Dive.

Note that every intermediate CA public key must be included in every truststore.

keytool can be used to get this certificate chain.

$ keytool -list -alias alfresco.ca -keystore ssl.repo.client.keystore -rfc
Alias name: alfresco.ca
Creation date: 20 Feb 2020
Entry type: PrivateKeyEntry
Certificate chain length: 2
Certificate[1]:
-----BEGIN CERTIFICATE-----
MIIFNTCCBB2gAwIBAgIQDZAM1h0f9komm5D7ivokHTANBgkqhkiG9w0BAQsFADBe
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
d3cuZGlnaWNlcnQuY29tMR0wGwYDVQQDExRHZW9UcnVzdCBSU0EgQ0EgMjAxODAe
Fw0xODAxMDIwMDAwMDBaFw0yMTAxMDExMjAwMDBaMIGaMQswCQYDVQQGEwJVUzEQ
MA4GA1UECBMHSW5kaWFuYTEVMBMGA1UEBxMMSW5kaWFuYXBvbGlzMSwwKgYDVQQK
EyNPbmVBbWVyaWNhIEZpbmFuY2lhbCBQYXJ0bmVycywgSW5jLjEZMBcGA1UECxMQ
TmV0d29yayBTZXJ2aWNlczEZMBcGA1UEAwwQKi5vbmVhbWVyaWNhLmNvbTCCASIw
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALYdHOLovHc2j5xQfBngerSsIFJa
VGOwsPQplUkQJ1P/V/gq9ihCtC/CqMFsQJRKJyoQ9Ii+CxsZLjeNVoPUl74AEoUX
gO+Mv1BpEAdV0KvC8gF9jUk0Rv/u9Mebt08uoGPKW6bb+XkphboopwhqNt42Ypk6
gwHW/HCyuCFXzWWT5ipcuK9vMpiNlZbBipicsX716AzYdOZ9uDSKpWbtxPriwsUe
Kbgkm5b2y3dH42bxjRs7ErNcVWF8jPiFUeDRFhA2gV2vbVfPr9jZV9be34xHJXv8
O3SDLjgdvay5128jqOhHOt8seNVW6+I3qpWjePPwWZs+FrgcMwOxBO+S+CkCAwEA
AaOCAbAwggGsMB8GA1UdIwQYMBaAFJBY/7CcdahRVHex7fKjQxY4nmzFMB0GA1Ud
DgQWBBRXtA41zjBtnwIQMyDegWj9frpzTjArBgNVHREEJDAighAqLm9uZWFtZXJp
Y2EuY29tgg5vbmVhbWVyaWNhLmNvbTAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYw
FAYIKwYBBQUHAwEGCCsGAQUFBwMCMD4GA1UdHwQ3MDUwM6AxoC+GLWh0dHA6Ly9j
ZHAuZ2VvdHJ1c3QuY29tL0dlb1RydXN0UlNBQ0EyMDE4LmNybDBMBgNVHSAERTBD
MDcGCWCGSAGG/WwBATAqMCgGCCsGAQUFBwIBFhxodHRwczovL3d3dy5kaWdpY2Vy
dC5jb20vQ1BTMAgGBmeBDAECAjB1BggrBgEFBQcBAQRpMGcwJgYIKwYBBQUHMAGG
Gmh0dHA6Ly9zdGF0dXMuZ2VvdHJ1c3QuY29tMD0GCCsGAQUFBzAChjFodHRwOi8v
Y2FjZXJ0cy5nZW90cnVzdC5jb20vR2VvVHJ1c3RSU0FDQTIwMTguY3J0MAkGA1Ud
EwQCMAAwDQYJKoZIhvcNAQELBQADggEBACvC+8nlAtCo7AMSP0ajPyobbNGOg/Ix
gVIKzQV8mnAntxjWn+SqnHGeWMqhvbsAeRDWkDc/XDq4Qq+QJMDM2ZyePENGDnvV
IjMPVHS+Nu1vc1JC9zn8vi9XKfB7OOcVOIJAp7ZZP9zAZLk79I0F6q6BeKj/d6my
jEZO//4QLK5FA+Bz8Ah0XP5Nt90x+pPi76yRbUuxgkJd5va9JfX2GM5cpw/BphjN
JeUhgFD8Gw8wxELwqNtc5QUlE0WlJSBrbRL9y+xuHcSYRlCsd3nEZ3h5PCtgjplz
iRxoB7R8KED+wH+MlWDSMbe+BtQ3rp9dPK2FYSZhQ3pIH4pR0+S+13Q=
-----END CERTIFICATE-----
Certificate[2]:
-----BEGIN CERTIFICATE-----
MIIEizCCA3OgAwIBAgIQBUb+GCP34ZQdo5/OFMRhczANBgkqhkiG9w0BAQsFADBh
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD
QTAeFw0xNzExMDYxMjIzNDVaFw0yNzExMDYxMjIzNDVaMF4xCzAJBgNVBAYTAlVT
MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j
b20xHTAbBgNVBAMTFEdlb1RydXN0IFJTQSBDQSAyMDE4MIIBIjANBgkqhkiG9w0B
AQEFAAOCAQ8AMIIBCgKCAQEAv4rRY03hGOqHXegWPI9/tr6HFzekDPgxP59FVEAh
150Hm8oDI0q9m+2FAmM/n4W57Cjv8oYi2/hNVEHFtEJ/zzMXAQ6CkFLTxzSkwaEB
2jKgQK0fWeQz/KDDlqxobNPomXOMJhB3y7c/OTLo0lko7geG4gk7hfiqafapa59Y
rXLIW4dmrgjgdPstU0Nigz2PhUwRl9we/FAwuIMIMl5cXMThdSBK66XWdS3cLX18
4ND+fHWhTkAChJrZDVouoKzzNYoq6tZaWmyOLKv23v14RyZ5eqoi6qnmcRID0/i6
U9J5nL1krPYbY7tNjzgC+PBXXcWqJVoMXcUw/iBTGWzpwwIDAQABo4IBQDCCATww
HQYDVR0OBBYEFJBY/7CcdahRVHex7fKjQxY4nmzFMB8GA1UdIwQYMBaAFAPeUDVW
0Uy7ZvCj4hsbw5eyPdFVMA4GA1UdDwEB/wQEAwIBhjAdBgNVHSUEFjAUBggrBgEF
BQcDAQYIKwYBBQUHAwIwEgYDVR0TAQH/BAgwBgEB/wIBADA0BggrBgEFBQcBAQQo
MCYwJAYIKwYBBQUHMAGGGGh0dHA6Ly9vY3NwLmRpZ2ljZXJ0LmNvbTBCBgNVHR8E
OzA5MDegNaAzhjFodHRwOi8vY3JsMy5kaWdpY2VydC5jb20vRGlnaUNlcnRHbG9i
YWxSb290Q0EuY3JsMD0GA1UdIAQ2MDQwMgYEVR0gADAqMCgGCCsGAQUFBwIBFhxo
dHRwczovL3d3dy5kaWdpY2VydC5jb20vQ1BTMA0GCSqGSIb3DQEBCwUAA4IBAQAw
8YdVPYQI/C5earp80s3VLOO+AtpdiXft9OlWwJLwKlUtRfccKj8QW/Pp4b7h6QAl
ufejwQMb455OjpIbCZVS+awY/R8pAYsXCnM09GcSVe4ivMswyoCZP/vPEn/LPRhH
hdgUPk8MlD979RGoUWz7qGAwqJChi28uRds3thx+vRZZIbEyZ62No0tJPzsSGSz8
nQ//jP8BIwrzBAUH5WcBAbmvgWfrKcuv+PyGPqRcc4T55TlzrBnzAzZ3oClo9fTv
O9PuiHMKrC6V6mgi0s2sa/gbXlPCD9Z24XUMxJElwIVTDuKB0Q4YMMlnpN/QChJ4
B0AFsQ+DU0NCO+f78Xf7
-----END CERTIFICATE-----

In the sample above, Certificate[2] content could be saved as alfresco-ca-root.cer to be imported in the repository truststore.

alfresco-ssl-generator's People

Contributors

aborroy avatar afaust avatar aitseitz avatar bhagyas avatar dsibilio avatar kmagdziarz avatar kotelnik avatar mstrankowski avatar silverskyvicto avatar sus4nne avatar tvhdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alfresco-ssl-generator's Issues

return status:403 when solr call alfresco

Hello,

I'm trying to add mutual TLS authentication to ACS 7.1.

Keystores and truststores have been generated using the alfresco-ssl-generator tool:

./run.sh -keysize 2048 -alfrescoversion community -alfrescoformat classic -keystorepass "Leencloud" -truststorepass "Leencloud"

then start solr:

./solr/bin/solr start -a "-Dcreate.alfresco.defaults=alfresco,archive
-Dsolr.ssl.checkPeerName=false
-Dsolr.allow.unsafe.resourceloading=true
-Dssl-keystore.password=Leencloud
-Dssl-keystore.aliases=ssl-alfresco-ca,ssl-repo-client
-Dssl-keystore.ssl-alfresco-ca.password=Leencloud
-Dssl-keystore.ssl-repo-client.password=Leencloud
-Dssl-truststore.password=Leencloud
-Dssl-truststore.aliases=ssl-alfresco-ca,ssl-repo,ssl-repo-client
-Dssl-truststore.ssl-alfresco-ca.password=Leencloud
-Dssl-truststore.ssl-repo.password=Leencloud
-Dssl-truststore.ssl-repo-client.password=Leencloud" -f

then I got the 403 error in solr log:

2022-04-20 21:31:10.361 ERROR (org.alfresco.solr.AlfrescoCoreAdminHandler@a567e72_Worker-2) [   ] o.a.s.t.AbstractTracker [alfresco / ACL@1591121623 / IT #1650461470009] Tracking failure. See the stacktrace below for further details.
org.alfresco.error.AlfrescoRuntimeException: 03200000 api/solr/aclchangesets return status:403
	at org.alfresco.solr.client.SOLRAPIClient.callRepository(SOLRAPIClient.java:1596)
	at org.alfresco.solr.client.SOLRAPIClient.getAclChangeSets(SOLRAPIClient.java:185)
	at org.alfresco.solr.tracker.AclTracker.checkRepoAndIndexConsistency(AclTracker.java:416)
	at org.alfresco.solr.tracker.AclTracker.trackRepository(AclTracker.java:397)
	at org.alfresco.solr.tracker.AclTracker.doTrack(AclTracker.java:160)
	at org.alfresco.solr.tracker.AbstractTracker.track(AbstractTracker.java:242)
	at org.alfresco.solr.tracker.ActivatableTracker.track(ActivatableTracker.java:97)
	at org.alfresco.solr.tracker.TrackerJob.execute(TrackerJob.java:60)
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
2022-04-20 21:31:10.361 ERROR (org.alfresco.solr.AlfrescoCoreAdminHandler@a567e72_Worker-3) [   ] o.a.s.t.AbstractTracker [archive / ACL@1504349981 / IT #1650461470009] Tracking failure. See the stacktrace below for further details.
org.alfresco.error.AlfrescoRuntimeException: 03200001 api/solr/aclchangesets return status:403
	at org.alfresco.solr.client.SOLRAPIClient.callRepository(SOLRAPIClient.java:1596)
	at org.alfresco.solr.client.SOLRAPIClient.getAclChangeSets(SOLRAPIClient.java:185)
	at org.alfresco.solr.tracker.AclTracker.checkRepoAndIndexConsistency(AclTracker.java:416)
	at org.alfresco.solr.tracker.AclTracker.trackRepository(AclTracker.java:397)
	at org.alfresco.solr.tracker.AclTracker.doTrack(AclTracker.java:160)
	at org.alfresco.solr.tracker.AbstractTracker.track(AbstractTracker.java:242)
	at org.alfresco.solr.tracker.ActivatableTracker.track(ActivatableTracker.java:97)
	at org.alfresco.solr.tracker.TrackerJob.execute(TrackerJob.java:60)
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
2022-04-20 21:31:11.276 ERROR (ForkJoinPool-5-worker-7) [   ] o.a.s.SolrInformationServer Unable to update the text content of node 665. See the stacktrace below for further details.
org.alfresco.error.AlfrescoRuntimeException: 03200002 GetTextContentResponse return status is 403
	at org.alfresco.solr.client.SOLRAPIClient.getTextContent(SOLRAPIClient.java:1047)
	at org.alfresco.solr.SolrInformationServer.addContentPropertyToDocUsingAlfrescoRepository(SolrInformationServer.java:2741)
	at org.alfresco.solr.SolrInformationServer.addContentToDoc(SolrInformationServer.java:2701)
	at org.alfresco.solr.SolrInformationServer.updateContent(SolrInformationServer.java:1931)
	at org.alfresco.solr.tracker.ContentTracker$ContentIndexWorkerRunnable.doWork(ContentTracker.java:192)
	at org.alfresco.solr.tracker.AbstractWorker.run(AbstractWorker.java:48)
	at org.alfresco.solr.tracker.ContentTracker.lambda$doTrack$0(ContentTracker.java:131)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:952)
	at java.base/java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:926)
	at java.base/java.util.stream.AbstractTask.compute(AbstractTask.java:327)
	at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:746)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)

I noticed the content in alfresco-ssl-generator-master/ssl-tool/keystores/solr/ssl-truststore-passwords.properties:

aliases=alfresco.ca,ssl.repo,ssl.repo.client
keystore.password=Leencloud
alfresco.ca.password=Leencloud
ssl.repo.password=Leencloud
ssl.repo.client.password=Leencloud

The aliases is alfresco.ca, not ssl.alfresco.ca.
So I change the solr start command params to:

-Dssl-truststore.aliases=alfresco-ca,ssl-repo,ssl-repo-client

But got the same error.

The key with alias metadata has been changed, re-instate the previous keystore

Hello,

I'm trying to add mutual TLS authentication to an already existing ACS 6.2 / ASS 1.3 installation.

Keystores and truststores have been generated using the alfresco-ssl-generator tool:

PASSWORD="myverysecretpassword"

git clone https://github.com/Alfresco/alfresco-ssl-generator
cd alfresco-ssl-generator/ssl-tool
./run.sh -alfrescoversion enterprise \
         -keysize 1024 \
         -keystoretype JCEKS \                                                                                 
         -truststoretype JCEKS \
         -keystorepass "$PASSWORD" \
         -truststorepass "$PASSWORD" \
         -encstorepass "$PASSWORD" \
         -encmetadatapass "$PASSWORD"\
         -cacertdname "/C=FR/ST=France/L=France/O=FOO/OU=BAR/CN=FOOBAR-ca" \
         -repocertdname "/C=FR/ST=France/L=France/O=FOO/OU=BAR/CN=FOOBAR-acs-repo" \
         -solrcertdname "/C=FR/ST=France/L=France/O=FOO/OU=BAR/CN=FOOBAR-acs-repo-client" \
         -browsercertdname "/C=FR/ST=France/L=France/O=FOO/OU=BAR/CN=FOOBAR-browser-client" \
         -caservername localhost \
         -alfrescoservername localhost \
         -solrservername localhost \
         -alfrescoformat classic

ACS and ASS have been configured as described on this page https://docs.alfresco.com/search-services/latest/install/options/#install-with-mutual-tls-zip

Solr starts without error and I've access to the Solr web UI using the browser certificate.
But ACS throws an error during the startup:

2021-03-02 10:14:13,673  ERROR [web.context.ContextLoader] [localhost-startStop-1] Context initialization failed
org.alfresco.error.AlfrescoRuntimeException: 02020000 Keystores are invalid
	at org.alfresco.encryption.EncryptionChecker$1.execute(EncryptionChecker.java:78)
	at org.alfresco.encryption.EncryptionChecker$1.execute(EncryptionChecker.java:1)
	at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:450)
	at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:319)
	at org.alfresco.encryption.EncryptionChecker.onBootstrap(EncryptionChecker.java:67)
	at org.springframework.extensions.surf.util.AbstractLifecycleBean.onApplicationEvent(AbstractLifecycleBean.java:56)
	at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEventInternal(SafeApplicationEventMulticaster.java:221)
	at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEvent(SafeApplicationEventMulticaster.java:186)
	at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEvent(SafeApplicationEventMulticaster.java:206)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:896)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:401)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:292)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
	at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:70)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4699)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5165)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:743)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:719)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:614)
	at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1823)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.alfresco.encryption.InvalidKeystoreException: The key with alias metadata has been changed, re-instate the previous keystore
	at org.alfresco.encryption.AlfrescoKeyStoreImpl.validateKeys(AlfrescoKeyStoreImpl.java:922)
	at org.alfresco.encryption.AlfrescoKeyStoreImpl.validateKeys(AlfrescoKeyStoreImpl.java:188)
	at org.alfresco.encryption.KeyStoreChecker.validateKeyStores(KeyStoreChecker.java:49)
	at org.alfresco.encryption.EncryptionChecker$1.execute(EncryptionChecker.java:73)
	... 29 more
Mar 02, 2021 10:14:13 AM org.apache.catalina.core.StandardContext listenerStart

unable to load CA private key

MacAir:~ alf$ ./alfresco-ssl-generator-master/ssl-tool/run.sh

ls: keystores: No such file or directory
Generating RSA private key, 1024 bit long modulus
...........................++++++
.....++++++
e is 65537 (0x10001)
Generating a 1024 bit RSA private key
.++++++
...............++++++
writing new private key to 'certificates/repository.key'

Using configuration from openssl.cnf
Error opening CA private key ./demoCA/private/cakey.pem
4501907052:error:02FFF002:system library:func(4095):No such file or directory:/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-22.260.1/libressl-2.6/crypto/bio/bss_file.c:255:fopen('./demoCA/private/cakey.pem', 'r')
4501907052:error:20FFF002:BIO routines:CRYPTO_internal:system lib:/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-22.260.1/libressl-2.6/crypto/bio/bss_file.c:257:
unable to load CA private key
MacAir:~ alf$

Need another way to check version of sed

On OSX you do have the ability to replace osx sed with GNU sed. In such an environment the if condition will fail.
https://github.com/Alfresco/alfresco-ssl-generator/blob/master/ssl-tool/run.sh#L163

Therefor, a better way to check the version of sed is needed.
Perhaps something like this?

strings /usr/bin/sed  | grep FreeBSD
$FreeBSD: src/usr.bin/sed/compile.c,v 1.28 2005/08/04 10:05:11 dds Exp $
$FreeBSD: src/usr.bin/sed/main.c,v 1.36 2005/05/10 13:40:50 glebius Exp $
$FreeBSD: src/usr.bin/sed/misc.c,v 1.10 2004/08/09 15:29:41 dds Exp $
$FreeBSD: src/usr.bin/sed/process.c,v 1.39 2005/04/09 14:31:41 stefanf Exp $

vs.

strings `which sed` |grep gnu
GNU sed home page: <https://www.gnu.org/software/sed/>.
General help using GNU software: <https://www.gnu.org/gethelp/>.
[email protected]
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
https://www.gnu.org/software/sed/
General help using GNU software: <https://www.gnu.org/gethelp/>

genrsa: Unrecognized flag truststorepass

I am not able to generate certificate with this command.

./run.sh -keystorepass “password" -truststorepass “password"

the folder keystores
├── alfresco

has no

├── keystore
│ ├── ssl.keystore
│ ├── ssl.truststor

When I run it, I have the message "genrsa: Unrecognized flag truststorepass."
I want to generate ssl certificate for alfresco community

Https not working for share page of alfresco

Not able to open share page with https.
steps i followed:
cd ssl-tool-win --> rum.cmd
keystores folder is generated in ssl-tool-win
docker-compose:
Alfresco_content_repository changes:
alfresco-global.properties:
dir.keystore=/usr/local/tomcat/alf_data/keystore
local.transform.service.enabled=false
solr.secureComms=https
encryption.ssl.keystore.location=${dir.keystore}/ssl.keystore
encryption.ssl.keystore.type=JCEKS
encryption.ssl.truststore.location=${dir.keystore}/ssl.truststore
encryption.ssl.truststore.type=JCEKS
encryption.keystore.location=${dir.keystore}/keystore
encryption.keystore.type=JCEKS
solr.host=localhost
solr.port=8983
solr.port.ssl=8983
conf/server.xml:

changes of alfresco-share :
share-config-custom.xml:



alfresco-noauth
Alfresco - unauthenticated access
Access to Alfresco Repository WebScripts that do not require authentication
alfresco
https://IPaddr:8443/alfresco/s
none

     <endpoint>
        <id>alfresco</id>
        <name>Alfresco - user access</name>
        <description>Access to Alfresco Repository WebScripts that require user authentication</description>
        <connector-id>alfresco</connector-id>
        <endpoint-url>https://IPaddr:8443/alfresco/s</endpoint-url>
        <identity>user</identity>
     </endpoint>

     <endpoint>
        <id>alfresco-feed</id>
        <name>Alfresco Feed</name>
        <description>Alfresco Feed - supports basic HTTP authentication via the EndPointProxyServlet</description>
        <connector-id>https</connector-id>
        <endpoint-url>https://IPaddr:8443/alfresco/s</endpoint-url>
        <basic-auth>true</basic-auth>
        <identity>user</identity>
     </endpoint>

     <endpoint>
        <id>alfresco-api</id>
        <parent-id>alfresco</parent-id>
        <name>Alfresco Public API - user access</name>
        <description>Access to Alfresco Repository Public API that require user authentication.
                     This makes use of the authentication that is provided by parent 'alfresco' endpoint.</description>
        <connector-id>alfresco</connector-id>
        <endpoint-url>https://IPaddr:8443/alfresco/api</endpoint-url>
        <identity>user</identity>
     </endpoint>
  </remote>

docker-compose :
for alfresco-content-repository: added below env
-Dalfresco.host=10.188.105.144
-Dalfresco.port=8443
-Dshare.port=9443
-Dshare.protocol=https
-Dshare.host=10.188.105.144
for alfresco-share:
environment:
REPO_HOST: "alfresco"
REPO_PORT: "8443"
JAVA_OPTS: "
-Xms500m
-Xmx500m
-Dalfresco.host=localhost
-Dalfresco.port=8443
-Dalfresco.context=alfresco
-Dalfresco.protocol=https
"
ports:
- 9443:8443

behavior: https://IP:8443/alfresco is opening , when i click on share, its redirecting to https://IP:9443/share
but share login page is not opening
kindly check and let me know if im missing anything

Enhance linux check for empty keystore folder

Situation:
The current run.sh script checks in line
https://github.com/Alfresco/alfresco-ssl-generator/blob/master/ssl-tool/run.sh#L122
if the target folder for generated keystores is not empty...in case it is not empty it skips further keystore generation...

if [ "$(ls $KEYSTORES_DIR)" ]; then   
 echo "Keystores folder is not empty, skipping generation process..."    
 exit 1 
fi

This works perfectly on the system I've tested it, but can have some tricky side effects....
The ls command is an alias in most linux distributions. This can lead to an unexpected behavior in certain environments when the ls commands is an alias for $ ls -al and list as well the . and `..`` folders.

Solution:
To prevent this in my opinion we have two options:

a) check if KEYSTORES_DIR is a directory

 if [ -d $KEYSTORES_DIR ]; then
   echo "Keystores folder is not empty, skipping generation process..."    
   exit 1 
 fi

b) make sure the ls command list the directory content without . and ..

if [ "$(ls -A $KEYSTORES_DIR)" ]; then   
   echo "Keystores folder is not empty, skipping generation process..."    
   exit 1 
 fi

from ls man pages:
-A, --almost-all
do not list implied . and ..

@aborroy:
As requested, I'll prepare an PullRequest for the b) solution with the ls -A parameter.
For final review, please execute your script via ansible and make sure the std error is not thrown on the environment where ls is an alias for ls -al:

- name: "Generate new Keystores on Host if keystore folder does not exist"
      ansible.builtin.shell:
        cmd: "{{ acs_home }}/alfresco-ssl-generator/ssl-tool/run.sh -keysize 2048 -alfrescoversion enterprise -alfrescoformat classic"
        chdir: "{{ acs_home }}/alfresco-ssl-generator/ssl-tool/"
        creates: "{{ acs_home }}/alfresco-ssl-generator/ssl-tool/keystores"
      register: keystore_generated
      when: not acs_keystore_folder.stat.exists | bool
      tags:
        - keystore

if [alt_names] >= 10 then all DNS.1x become DNS.1

Hi Angel,
I was trying to define more than 9 SANs but when I run ./run.sh openssl.conf gets modified in a weird way ... example:

openssl.conf (edited by me)
[...]
[alt_names]
DNS.1 = localhost
DNS.2 = 127.0.0.1
DNS.3 = alfresco-local
DNS.4 = alfresco-remote
DNS.5 = solr-local
DNS.6 = solr-remote
DNS.7 = solr7
DNS.8 = solr8
DNS.9 = solr9
DNS.10 = solr10
DNS.11 = solr11

then I run : ./run.sh

I open openssl.conf again:

[...]
[alt_names]
DNS.1 = localhost
DNS.2 = 127.0.0.1
DNS.3 = alfresco-local
DNS.4 = alfresco-remote
DNS.5 = solr-local
DNS.6 = solr-remote
DNS.7 = solr7
DNS.8 = solr8
DNS.9 = solr9
DNS.1 = localhost
DNS.1 = localhost

could you please have a look at it when possible?

Generated /keystore/client/browser.p12 in linux run.sh is defect

Hi @aborroy

has mentioned in discord earlier today, I've discoverd the issue that the /keystore/client/browser.p12 is not working, when creating the file with the following command:

/alfresco-ssl-generator/ssl-tool/run.sh -keysize 2048 -alfrescoversion enterprise -alfrescoformat {{ acs_ssl_tool_alfresco_keystore_format }}"
➜  ~ openssl version
OpenSSL 1.1.1f  31 Mar 2020

Result: browser.p12 is broken
image

On the other hand the /certifcates/browser.p12 created is working correctly:

image

as well as the /certificates/solr.p12:

image

I looks to me that the keystore/client/browser.p12 does not include any valid solr certificates...

Generate for acs7

Hello,

I generated keys with alfresco-ssl-generator.
When I specify alfrescoformat to current (ACS7) i have all my key/trust store

I had no problem with solr setting up TLS : i can put passwords in solr.in.sh and/or in the service's options.
I had a problem with alfresco to cummunicate with solr. In order to solve this problem i had to put in my alfresco-global.properties those two properties

encryption.ssl.keystore.keyMetaData.location 
encryption.ssl.truststore.keyMetaData.location 

But... (this is the problem) the ssl generator doesn't deliver password.properties files. To solve that, i made a file with my favortie editor and it's works.
Is there any properties or Java arguments to put to specify keystore's password like a encryption.ssl.keystore.password and encryption.ssl.truststore.password ?

Thank you

[IMPROVEMENT] Ability to invoke basic functions independently

The process to generate and assemble keystore files involves several functions:

  • Generate a new keystore for repository encryption purposes (alfresco/keystore)
  • Generate a new CA Entity to issue digital certificates
  • Generate truststore and keystore for Alfresco Repository (alfresco)
  • Generate truststore and keystore for Search Services (solr)
  • Generate truststore and keystore for Apache Zeppelin (zeppelin) - Only applies to Enterprise deployments, SOLR keystore and truststore can be reused for this configuration
  • Generate browser client certificate for Search Services (client)

Improvement

Create a new set of command line parameters to cover these options:

  • -encryption creates the alfresco/keystore file

    • STORE_TYPE: PKCS12, JCEKS
    • KEY_ALG: AES -keysize 256, DESede
  • -ca creates a new CA Entity

    • CA_DNAME, for instance "/C=GB/ST=UK/L=Maidenhead/O=Alfresco Software Ltd./OU=Unknown/CN=Custom Alfresco CA"
    • KEY_SIZE: 2048, 4096
    • PASS: default password
    • DAYS: caducity
  • -alfresco-key creates keystore for Repository

    • KEY_SIZE: 2048, 4096
    • STORE_TYPE: PKCS12, JCEKS
    • PASS: default password
    • DAYS: caducity
    • REPO_CERT_DNAME: for instance "/C=GB/ST=UK/L=Maidenhead/O=Alfresco Software Ltd./OU=Unknown/CN=Custom Alfresco Repository"
    • ALFRESCO_SERVER_NAME, for instance "localhost"
  • -solr-key creates keystore for Search Services

    • KEY_SIZE: 2048, 4096
    • STORE_TYPE: PKCS12, JCEKS
    • PASS: default password
    • DAYS: caducity
    • SOLR_CLIENT_CERT_DNAME: for instance "/C=GB/ST=UK/L=Maidenhead/O=Alfresco Software Ltd./OU=Unknown/CN=Custom Alfresco Repository Client"
    • SOLR_SERVER_NAME, for instance "localhost"
  • -alfresco-trust creates truststore for Repository

    • SOLR_KEYSTORE: the path of the SOLR keystore
    • SOLR_PASS: the password for the SOLR keystore
  • -solr-trust creates truststore for Search Service

    • REPO_KEYSTORE: the path of the Repository keystore
    • REPO_PASS: the password for the Repository keystore
  • -solr-client creates the browser client certificate

    • KEY_SIZE: 2048, 4096
    • PASS: default password
    • DAYS: caducity
    • BROWSER_CLIENT_CERT_DNAME: for instance "/C=GB/ST=UK/L=Maidenhead/O=Alfresco Software Ltd./OU=Unknown/CN=Custom Browser Client"

[IMPROVEMENT] support config file for defaults

alfresco-ssl-generator should support a config file to store defaults and custom overwrites to avoid passing everything as parameters e.g.

~/.alfresco-ssl-generator/DEFAULTS

SSL_BASE=/opt/alfresco/alf_data/ssl
SSL_KEYSTORE=$SSL_BASE/keystore

ALF_CA_CN_NAME=Custom Alfresco CA
ALF_REPO_CN_NAME=Custom Alfresco Repository
ALF_SOLR_CN_NAME=Alfresco Solr
ALF_REPO_CLIENT_CN_NAME=Custom Alfresco Repository Client
ALF_SOLR_CLIENT_CN_NAME=Custom Alfresco Solr Client
ALF_OU=Unknown
ALF_L=Maidenhead
ALF_O=Alfresco Software Ltd.
ALF_ST=UK
ALF_C=GB

# server names, to be used as Alternative Name in the certificates
ALFRESCO_SERVER_NAME=localhost
SOLR_SERVER_NAME=localhost

KEY_SIZE=4096
KEYSTORE_TYPE=JCEKS # (PKCS12, JKS, JCEKS)
TRUSTSTORE_TYPE=JCEKS # (JKS, JCEKS)

# Default password for every keystore and private key
KEYSTORE_PASS=keystore
# Default password for every truststore
TRUSTSTORE_PASS=$KEYSTORE_PASS

# Encryption secret key passwords
ENC_STORE_PASS=$KEYSTORE_PASS
ENC_METADATA_PASS=$KEYSTORE_PASS

KEY_SIZE=4096
KEY_ALG=RSA

META_KEYSTORE_KEY_ALG=AES
META_KEYSTORE_KEY_SIZE=256

~/.alfresco-ssl-generator/CUSTOM

KEYSTORE_PASS=myverysecretPW!
TRUSTSTORE_PASS=$KEYSTORE_PASS
ENC_STORE_PASS=$KEYSTORE_PASS
ENC_METADATA_PASS=$KEYSTORE_PASS

Encryption keystore format and Key algorithm wrong value when alfrescoformat is classic?

After downloading the installation zip for ACS 6.2.1 I tried to use the linux ssl generator but it was creating the wrong type of keystores. The type is always "PKCS12" and algorithm is also always "-keyalg AES -keysize 256" despite setting the alfrescoformat to "classic".

After checking the bash run.sh script I saw that the setting of the Key algorithm (Line 100-105) and the Encryption keystore format set (Line 85-90) are outside of the generate function. So they will be executed BEFORE the parameters are loaded.
Because the default ALFRESCO_FORMAT is initiated as "current" the settings for "current" are always set in the two if else blocks.
I moved both if/else blocks in the top of the generate function and now the keystores are created correctly.

Regards!
Carlo / Harmony group

Java Environment Variables - please provide a working example

Hi Angel, me... again.
"For the current format all the passwords are passed to the applications using Java Environment Variables, so the password files are not required any more."

I'm doing something wrong because I have defined absolutely nothing in alfresco-global.properties , I have this in setenv.sh 👍
[...]
JAVA_OPTS="$JAVA_OPTS
-Dencryption.keystore.type=JCEKS
-Dencryption.cipherAlgorithm=AES
-Dencryption.keyAlgorithm=AES
-Dencryption.keystore.location=/opt/alfresco/alf_data/keystore/keystore
-Dmetadata-keystore.password=password
-Dmetadata-keystore.aliases=metadata
-Dmetadata-keystore.metadata.password=password
-Dmetadata-keystore.metadata.algorithm=AES
-Ddir.keystore=/opt/alfresco/alf_data/keystore
-Dencryption.ssl.keystore.location=/opt/alfresco/alf_data/keystore/ssl.keystore
-Dencryption.ssl.keystore.type=JCEKS
-Dencryption.ssl.keystore.password=keystore
-Dencryption.ssl.keystore.metadata.password=keystore
-Dencryption.ssl.truststore.location=/opt/alfresco/alf_data/keystore/ssl.truststore
-Dencryption.ssl.truststore.type=JCEKS
-Dencryption.ssl.truststore.password=truststore" ;

but still I get a: "java.lang.IllegalArgumentException: password can't be null" so I guess my Java Environment Variables are not enough.

2022-11-18 21:15:00,010 ERROR [quartz.core.ErrorLogger] [SearchScheduler_Worker-4] Job (Solr.SolrWatcher threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: org.alfresco.error.AlfrescoRuntimeException: 10180362 Unable to create SSL context]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: org.alfresco.error.AlfrescoRuntimeException: 10180362 Unable to create SSL context
at org.alfresco.encryption.ssl.AuthSSLProtocolSocketFactory.getSSLContext(AuthSSLProtocolSocketFactory.java:130)
at org.alfresco.encryption.ssl.AuthSSLProtocolSocketFactory.createSocket(AuthSSLProtocolSocketFactory.java:165)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.alfresco.httpclient.RequestHeadersHttpClient.executeMethod(RequestHeadersHttpClient.java:84)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at org.alfresco.httpclient.RequestHeadersHttpClient.executeMethod(RequestHeadersHttpClient.java:69)
at org.alfresco.repo.search.impl.solr.AbstractSolrAdminHTTPClient.getOperation(AbstractSolrAdminHTTPClient.java:73)
at org.alfresco.repo.solr.SOLRAdminClient.executeAction(SOLRAdminClient.java:221)
at org.alfresco.repo.solr.SOLRAdminClient$SolrTracker.pingSolr(SOLRAdminClient.java:333)
at org.alfresco.repo.solr.SOLRWatcherJob.execute(SOLRWatcherJob.java:54)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
... 1 more
Caused by: org.alfresco.error.AlfrescoRuntimeException: 10180361 Unable to create key manager
at org.alfresco.encryption.AlfrescoKeyStoreImpl.createKeyManagers(AlfrescoKeyStoreImpl.java:337)
at org.alfresco.encryption.ssl.AuthSSLProtocolSocketFactory.createSSLContext(AuthSSLProtocolSocketFactory.java:103)
at org.alfresco.encryption.ssl.AuthSSLProtocolSocketFactory.getSSLContext(AuthSSLProtocolSocketFactory.java:124)
... 15 more
Caused by: java.lang.IllegalArgumentException: password can't be null
at java.base/com.sun.crypto.provider.KeyProtector.(KeyProtector.java:114)
at java.base/com.sun.crypto.provider.JceKeyStore.engineGetKey(JceKeyStore.java:129)
at java.base/java.security.KeyStore.getKey(KeyStore.java:1057)
at java.base/sun.security.ssl.SunX509KeyManagerImpl.(SunX509KeyManagerImpl.java:145)
at java.base/sun.security.ssl.KeyManagerFactoryImpl$SunX509.engineInit(KeyManagerFactoryImpl.java:70)
at java.base/javax.net.ssl.KeyManagerFactory.init(KeyManagerFactory.java:271)
at org.alfresco.encryption.AlfrescoKeyStoreImpl.createKeyManagers(AlfrescoKeyStoreImpl.java:332)
... 17 more

Thanks for your valuable help!

[IMPROVEMENT] Naming scheme

Current naming scheme may be confusing:

keystores/
├── alfresco
│   ├── keystore
│   ├── ssl.keystore
│   └── ssl.truststore
├── client
│   └── browser.p12
├── solr
│   ├── ssl-repo-client.keystore
│   └── ssl-repo-client.truststore
└── zeppelin
    ├── ssl-repo-client.keystore
    └── ssl-repo-client.truststore

Improvement

Simplify naming to avoid confusions:

  • keystore >> metadata.keystore
  • ssl.keystore >> repo.keystore
  • ssl.truststore >> repo.truststore
  • ssl-repo-client.keystore >> solr.keystore
  • ssl-repo-client.truststore >> solr.truststore

Additionally internal alias naming may be revisited.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.