This method adds a new key to a zone.
The key can either be generated or imported by supplying the ``content`` parameter.
+ if ``content``, ``bits`` and ``algo`` are null, a key will be generated based
+ on the :ref:`setting-default-ksk-algorithm` and :ref:`setting-default-ksk-size`
+ sttings for a KSK and the :ref:`setting-default-zsk-algorithm` and :ref:`setting-default-zsk-size`
+ options for a ZSK.
+
:param server_id: The name of the server
:param zone_id: The id value of the :json:object:`Zone`
:reqjson string content: The private key to use (The format used is compatible with BIND and NSD/LDNS)
int64_t insertedId;
if (content.is_null()) {
- int bits = 0;
+ int bits = keyOrZone ? ::arg().asNum("default-ksk-size") : ::arg().asNum("default-zsk-size");
auto docbits = document["bits"];
if (!docbits.is_null()) {
if (!docbits.is_number() || (fmod(docbits.number_value(), 1.0) != 0) || docbits.int_value() < 0) {
bits = docbits.int_value();
}
}
- int algorithm = 13; // ecdsa256
+ int algorithm = DNSSECKeeper::shorthand2algorithm(keyOrZone ? ::arg()["default-ksk-algorithm"] : ::arg()["default-zsk-algorithm"]);
auto providedAlgo = document["algo"];
if (providedAlgo.is_string()) {
algorithm = DNSSECKeeper::shorthand2algorithm(providedAlgo.string_value());