-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RHCS-5445] Implement new SSN legacy2 generator for CA
The legacy id generator can introduce gaps when new ranges are allocated because of some conversion errors between hex and decimal. A new serial id generator has been introduced to avoid gap problems. The old and new serial generator are described in the following pages: - SSNv1: https://github.com/dogtagpki/pki/wiki/Sequential-Serial-Numbers-v1 - SSNv2://github.com/dogtagpki/pki/wiki/Sequential-Serial-Numbers-v2 Instances using SSNv1 can migrate to the SSNv2 using the commands described here: - https://github.com/dogtagpki/pki/wiki/Migrating-to-Sequential-Serial-Numbers-v2 If there is no need to avoid gaps it is better to avoid the migration. NOTE: the links above provide documentation to the newer version of dogtag. The porting to this release has some limitations to consider: - the new generator is available only to the CA ids; - some of the parameter are not customisable with `pkispawn` (e.g. increment, transfer, etc..) only the initial range limits. Additionally, during the migration of a clone it is required to provide new range limits even they will be overwritten with values coming from master.
- Loading branch information
Showing
25 changed files
with
1,445 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
base/ca/src/main/java/org/dogtagpki/server/ca/cli/CADBInitCLI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// Copyright Red Hat, Inc. | ||
// | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
// | ||
package org.dogtagpki.server.ca.cli; | ||
import org.dogtagpki.cli.CLI; | ||
import org.dogtagpki.server.cli.SubsystemDBInitCLI; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.netscape.certsrv.dbs.repository.IRepository.IDGenerator; | ||
import com.netscape.cmscore.apps.DatabaseConfig; | ||
import com.netscape.cmscore.dbs.CertificateRepository; | ||
/** | ||
* @author Endi S. Dewata | ||
*/ | ||
public class CADBInitCLI extends SubsystemDBInitCLI { | ||
public static Logger logger = LoggerFactory.getLogger(CADBInitCLI.class); | ||
public CADBInitCLI(CLI parent) { | ||
super("init", "Initialize CA database", parent); | ||
} | ||
@Override | ||
public void init(DatabaseConfig dbConfig) throws Exception { | ||
super.init(dbConfig); | ||
String value = dbConfig.getString( | ||
CertificateRepository.PROP_CERT_ID_GENERATOR, | ||
CertificateRepository.DEFAULT_CERT_ID_GENERATOR); | ||
serialIDGenerator = IDGenerator.fromString(value); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
base/ca/src/main/java/org/dogtagpki/server/ca/cli/CAIdCLI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// Copyright Red Hat, Inc. | ||
// | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
// | ||
package org.dogtagpki.server.ca.cli; | ||
|
||
import org.dogtagpki.cli.CLI; | ||
|
||
/** | ||
* @author Marco Fargetta {@literal <[email protected]>} | ||
*/ | ||
public class CAIdCLI extends CLI { | ||
public CAIdCLI(CLI parent) { | ||
super("id", "CA id generator management commands", parent); | ||
|
||
addModule(new CAIdGeneratorCLI(this)); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
base/ca/src/main/java/org/dogtagpki/server/ca/cli/CAIdGeneratorCLI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// Copyright Red Hat, Inc. | ||
// | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
// | ||
package org.dogtagpki.server.ca.cli; | ||
|
||
import org.dogtagpki.cli.CLI; | ||
|
||
/** | ||
* @author Marco Fargetta {@literal <[email protected]>} | ||
*/ | ||
public class CAIdGeneratorCLI extends CLI { | ||
|
||
public CAIdGeneratorCLI(CLI parent) { | ||
super("generator", "CA id generator commands", parent); | ||
|
||
addModule(new CAIdGeneratorUpdateCLI(this)); | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
base/ca/src/main/java/org/dogtagpki/server/ca/cli/CAIdGeneratorUpdateCLI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// Copyright Red Hat, Inc. | ||
// | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
// | ||
package org.dogtagpki.server.ca.cli; | ||
|
||
import org.dogtagpki.cli.CLI; | ||
import org.dogtagpki.server.cli.SubsystemIdGeneratorUpdateCLI; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.netscape.certsrv.dbs.repository.IRepository.IDGenerator; | ||
import com.netscape.cmscore.apps.DatabaseConfig; | ||
import com.netscape.cmscore.dbs.CertificateRepository; | ||
import com.netscape.cmscore.ldapconn.LdapBoundConnection; | ||
|
||
/** | ||
* @author Marco Fargetta {@literal <[email protected]>} | ||
*/ | ||
public class CAIdGeneratorUpdateCLI extends SubsystemIdGeneratorUpdateCLI { | ||
private static final Logger logger = LoggerFactory.getLogger(CAIdGeneratorUpdateCLI.class); | ||
|
||
public CAIdGeneratorUpdateCLI(CLI parent) { | ||
super(parent); | ||
} | ||
|
||
@Override | ||
protected void updateSerialNumberRangeGenerator(LdapBoundConnection conn, | ||
DatabaseConfig dbConfig, String baseDN, String newRangesName, | ||
IDGenerator newGenerator, String hostName, String securePort) throws Exception { | ||
String value = dbConfig.getString( | ||
CertificateRepository.PROP_CERT_ID_GENERATOR, | ||
null); | ||
if (value == null) { | ||
idGenerator = IDGenerator.LEGACY; | ||
} else { | ||
idGenerator = IDGenerator.fromString(value); | ||
} | ||
if (newGenerator == IDGenerator.LEGACY_2 && idGenerator == IDGenerator.LEGACY) { | ||
dbConfig.put(CertificateRepository.PROP_CERT_ID_GENERATOR, newGenerator.toString()); | ||
} | ||
super.updateSerialNumberRangeGenerator(conn, dbConfig, baseDN, newRangesName, newGenerator, hostName, securePort); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.