Glassfish
EJBCA 6.x has not yet been officially deployed on Glassfish. The following notes can be used as hints for anyone interested in working on Glassfish support.
EJBCA 4.x has been tested with Glassfish v2.1.1.
Ensure to install Unlimited Strength Jurisdiction Policy Files for Java. For download, refer to the Oracle website.
Using Derby Database (Glassfish built-in)
Using Derby Database, follow the steps below:
Start JavaDB and create the database instance:
cd$APPSRV_HOMEbin/asadminstart-databaseexportDERBY_HOME=$APPSRV_HOME/javadbjavadb/bin/ijij> connect'jdbc:derby://localhost:1527/ejbca;create=true';ij> quit;Start the application server:
bin/asadminstart-domainThe default user/password for the web console is admin/adminadmin. Access the Glassfish admin console at: http://127.0.0.1:4848/.
Create a connection pool for your database by selecting Resources > JDBC > Connection Pools in the Admin console.
When adding a Derby Pool, use the values: Name=EjbcaPool, Type=javax.sql.DataSource, Vendor=JavaDB.
Properties: user=APP, password=APP, DatabaseName=ejbca
Save and use the Ping-button for the pool. If you get Parameter wrong for this method : off, go to Additional Properties and delete Ssl. Alternatively, use the following CLI command:bin/asadmincreate-jdbc-connection-pool --datasourceclassname org.apache.derby.jdbc.ClientDataSource --property user=APP:password=APP:DatabaseName=ejbca:ServerName=localhost:port=1527 EjbcaPoolCreate a datasource called jdbc/EjbcaDS under Resources > JDBC > JDBC Resources in the Admin console. Use the connection pool you just created.
Alternatively, use the following CLI command:
bin/asadmincreate-jdbc-resource --connectionpoolid EjbcaPool jdbc/EjbcaDSIf security is enabled, add the following:
--user admin --passwordfile pwd.txtas command line parameters where pwd.txt contains AS_ADMIN_PASSWORD=adminadmin.
Using MySQL Database
Using MySQL Database, follow the steps below:
Start the database and create the MySQL database "ejbca".
Grant privileges to the "ejbca" user with password "ejbca_pwd" (ensure not to use this password in production!)
Copy the MySQL JDBC JAR to APPSRV_HOME/lib/.
Start the application server:
asadmin start-domainAdd the Connection Pool and DataSource from the Glassfish Admin Console (see "Derby"), or use command line:
asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource --property user=ejbca:password=ejbca_pwd:DatabaseName=ejbca:ServerName=localhost:port=3306 EjbcaPoolasadmin create-jdbc-resource --connectionpoolid EjbcaPool jdbc/EjbcaDS
Configure EJBCA
Edit conf/ejbca.properties and at least set appserver.home.
Edit conf/log4j-glassfish.xml to configure EJBCA logging.
Edit conf/database.properties and at least set the database settings for your chosen database. Derby and MySQL has been tested with Glassfish.
Edit conf/web.properties and set the desired values and the http/s ports (default 8080 and 8181) for your installation.
Deploy and Setup
If your appserver does not require a password for deployment (asadmin deploy), you can build and deploy EJBCA with:
ant cleanant bootstrapor otherwise with an additional step:
ant cleanantasadmin deploy --precompilejsp $EJBCA_HOME/dist/ejbca.earVerify in APPSRV_HOME/domains/domain1/logs/server.log.
To install EJBCA, run:
ant installConfigure SSL in Glassfish under Configuration > HTTP Service > HTTP Listeners > http-listener-2, SSL tab
Client Authentication: Enabled
Certificate Nickname: s1as (get alias name by running 'keytool -list -v -keystore $APPSRV_HOME/domains/domain1/config/keystore.jks', password changeit)
SSL3: Enabled
Ciphers Suite: All
Add CA certificate to the cacerts file:
cd $EJBCA_HOMEkeytool -exportcert -keystore p12/truststore.jks -file p12/managementca.der -storepass changeit -alias managementcaInstall the CA certificate in the application servers truststore. On Glassfish open source:
keytool -delete -keystore $APPSRV_HOME/domains/domain1/config/cacerts.jks -alias managementca -storepass changeit(will failifthishasn't been done before)keytool -importcert -keystore $APPSRV_HOME/domains/domain1/config/cacerts.jks -file p12/managementca.der -alias managementca -storepass changeitOn Glassfish Enterprise:
cd $APPSRV_HOME/domains/domain1/config/usr/sfw/bin/certutil -A -n managementca -t"p,p,p"-i p12/managementca.der -d .verify that managementca has been added to the store with:
/usr/sfw/bin/certutil -L -d .(Optional) Replace the SSL keystore and truststore with default passwords.
To change the keystore passwords in a production environment, edit both the http-listener and the IIOP-listeners:cd $EJBCA_HOMEcp p12/tomcat.jks p12/keystore.jkskeytool -list -keystore p12/keystore.jks -storepass serverpwdRead the aliasforthe"PrivateKeyEntry"e.g.'localhost'.keytool -keypasswd -keystore p12/keystore.jks -alias localhost -storepass serverpwd -keypass serverpwd -newchangeitkeytool -storepasswd -keystore p12/keystore.jks -storepass serverpwd -newchangeitkeytool -changealias -keystore p12/keystore.jks -alias localhost -destalias s1as -keypass changeit -storepass changeitcp p12/keystore.jks $APPSRV_HOME/domains/domain1/config/keystore.jksRestart the server:
asadmin stop-domainasadmin start-domainAccess protected EJBCA pages:
Import $EJBCA_HOME/p12/superadmin.p12 in your browser, go to https://127.0.0.1:8181/ejbca/ and click Administration to get to the Admin GUI(Optional) To change how often an EJBCA Service can run, select Configuration > EJB Container > EJB Timer Service > Minimum Delivery Interval:1000 and restart the application server.
This can also be changed using the minimum-delivery-interval-in-millis attribute in the domain.xml file when the appserver is not running.(Optional) Apply a workaround to enable redeployment without application server restart. For more information, refer to ECA-1887.
Glassfish Ubuntu Package
The above instructions are tested on the official release from Glassfish's homepage.
If using the Glassfish package on Ubuntu, it may be needed to modify the following to make it work with the Ubuntu 9.04 Glassfish package.
Modify /usr/bin/asadmin:
#GF_DOMAIN_DIR=$HOME/glassfishv2 GF_DOMAIN_DIR=/var/lib/glassfishv2/domainsSet APPSRV_HOME to /usr/share/glassfishv2
The Ubuntu package has the domains and binaries separated. When following the install instructions, point to /var/lib/glassfishv2/[directory] instead of $APPSRV_HOME/[directory].