Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renew samba fixture expired test certificates #68985

Merged
merged 3 commits into from
Feb 15, 2021

Conversation

jkakavas
Copy link
Member

Add a README file for how these certificates can be renewed in the
future, when the need arises again.

Add a README file for how these certificates can be renewed in the
future, when the need arises again.
@jkakavas jkakavas added >test-failure Triaged test failures from CI :Security/TLS SSL/TLS, Certificates labels Feb 15, 2021
@elasticmachine elasticmachine added the Team:Security Meta label for security team label Feb 15, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security (Team:Security)

@hendrikmuhs
Copy link

hendrikmuhs commented Feb 15, 2021

Due to the cryptic failure, it took time to find the root cause, this was the error message:

13:02:22 + ldapmodify -D Administrator@ad.test.elasticsearch.com -w Passw0rd -H ldaps://127.0.0.1:636 -f /tmp/entrymods -v
13:02:22 ldap_initialize( ldaps://127.0.0.1:636/??base )
13:02:22 ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)

It would therefore be nice to e.g. add something like:

if ! openssl x509 -noout -checkend 86400  -in /fixture/src/main/resources/certs/ca.pem; then echo "Certificate has expired, please check the readme for instructions."; fi

to src/main/resources/provision/installsmb.sh and potentially other places.

update: requires adding the installation of openssl in Dockerfile

@jkakavas
Copy link
Member Author

to src/main/resources/provision/installsmb.sh and potentially other places.

Agreed, but I think we can do a better job with the fixture and I don't want us to block intake for more than necessary while we think/iterate on solutions. If you don't mind @hendrikmuhs , I'll merge this with just the certificate changes and open an issue to properly address the fixture's resilience

@hendrikmuhs
Copy link

to src/main/resources/provision/installsmb.sh and potentially other places.

Agreed, but I think we can do a better job with the fixture and I don't want us to block intake for more than necessary while we think/iterate on solutions. If you don't mind @hendrikmuhs , I'll merge this with just the certificate changes and open an issue to properly address the fixture's resilience

👍, improvements can be done in a follow-up

[source,shell]
-----------------------------------------------------------------------------------------------------------
elasticsearch-certutil cert --pem --ca-cert ${PWD}/ca.pem --ca-key ${PWD}/ca.key \
--dns localhost --ip 127.0.0.1,0:0:0:0:0:0:0:1 --name samba4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--dns localhost --ip 127.0.0.1,0:0:0:0:0:0:0:1 --name samba4
--dns localhost --ip 127.0.0.1,0:0:0:0:0:0:0:1 --name samba4 --out ${PWD}/samba4.zip

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it's good to be explicit


=== Generate certificates for the Samba server

These keys and certificates are copied by installsmb.sh for the Samba server to use for TLS. See `../resources/installsmb.sh`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
These keys and certificates are copied by installsmb.sh for the Samba server to use for TLS. See `../resources/installsmb.sh`
These keys and certificates are copied by installsmb.sh for the Samba server to use for TLS. See `../provision/installsmb.sh`

keytool -keystore ../../../../../../../x-pack/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ADtrust.jks -storepass changeit -delete -noprompt -alias smb_cert
keytool -keystore ../../../../../../../x-pack/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ADtrust.jks -storepass changeit -importcert -file cert.pem -alias smb_cert -noprompt
keytool -keystore ../../../../../../../x-pack/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ADtrust.jks -storepass changeit -delete -noprompt -alias mykey
keytool -keystore ../../../../../../../x-pack/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ADtrust.jks -storepass changeit -importcert -file cert.pem -alias mykey -noprompt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested UserAttributeGroupsResolverTests and ActiveDirectoryGroupsResolverTests (the only users of ADtrust.jks) with only the smb_ca entry in the truststore (no smb_cert and no mykey entries) and they pass.

Might be worth adjusting the truststore while we're at it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do since I'll respin this eitherway, but we definitely need to clean our key/cert resources up soon. I think we have an open issue about this somewhere too

Copy link

@hendrikmuhs hendrikmuhs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jkakavas jkakavas merged commit a4986b3 into elastic:master Feb 15, 2021
jkakavas added a commit to jkakavas/elasticsearch that referenced this pull request Feb 15, 2021
Renew our smb-fixture expired test certificates that are in use in the
fixture and in various tests for LDAP and AD. 
Add a README file for how these certificates can be renewed in the
future, when the need arises again.
jkakavas added a commit to jkakavas/elasticsearch that referenced this pull request Feb 15, 2021
Renew our smb-fixture expired test certificates that are in use in the
fixture and in various tests for LDAP and AD. 
Add a README file for how these certificates can be renewed in the
future, when the need arises again.
jkakavas added a commit to jkakavas/elasticsearch that referenced this pull request Feb 15, 2021
Renew our smb-fixture expired test certificates that are in use in the
fixture and in various tests for LDAP and AD. 
Add a README file for how these certificates can be renewed in the
future, when the need arises again.
jkakavas added a commit that referenced this pull request Feb 15, 2021
Renew our smb-fixture expired test certificates that are in use in the
fixture and in various tests for LDAP and AD. 
Add a README file for how these certificates can be renewed in the
future, when the need arises again.
jkakavas added a commit that referenced this pull request Feb 15, 2021
Renew our smb-fixture expired test certificates that are in use in the
fixture and in various tests for LDAP and AD. 
Add a README file for how these certificates can be renewed in the
future, when the need arises again.
jkakavas added a commit that referenced this pull request Feb 15, 2021
Renew our smb-fixture expired test certificates that are in use in the
fixture and in various tests for LDAP and AD. 
Add a README file for how these certificates can be renewed in the
future, when the need arises again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Security/TLS SSL/TLS, Certificates Team:Security Meta label for security team >test-failure Triaged test failures from CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants