[[certificateStorage]]
= Storing and managing certificates
:author: Wojciech Kapcia

== Filesystem

By default Tigase loads and stores certificates in `certs/` subdirectory. Each _domain_ certificate should be stored in a file which filename consists of domain name and `.pem` extension, i.e. `<domain>.pem`. For example for domain tigase.net it would be `certs/tigase.net.pem`.

NOTE: Tigase tries to be _smart_ and automatically detects wildcard domain and alternative domains so it's not needed to duplicate same certificate in multiple files to match domains.

== Database repository

Alternatively it's possible to use database as a storage for the certificates. Upon enabling it certificates won't be read nor stored to the filesystem. You can enable it by adding `repository () {}` bean to `'certificate-container' () {}` in your TDSL configuration file:

[source]
----
'certificate-container' () {
	repository () {}
}
----

If you are using database repository then you manage/update certificates using either ad-hoc command `Add SSL certificate` from _VHost Manager_ or via HTTP REST API.
