@@ -104,7 +104,7 @@ Recipient
104104Recipient::makeEIDServer (std::vector<uint8_t > cert, std::string server_id)
105105{
106106 Certificate x509 (cert);
107- auto label = BuildLabelEID (cert);
107+ auto label = BuildLabelEID (cert, time ( nullptr ) + 60 * 60 * 24 * 31 * 6 ); // 6 months
108108 return makeServer (std::move (label),
109109 x509.getPublicKey (), x509.getAlgorithm () == Certificate::Algorithm::RSA ? RSA : ECC, std::move (server_id));
110110}
@@ -143,7 +143,7 @@ static constexpr std::string_view type_strs[] = {
143143};
144144
145145std::string
146- Recipient::buildLabel (std::vector<std::pair<std::string_view, std::string_view>> components)
146+ Recipient::buildLabel (const std::vector<std::pair<std::string_view, std::string_view>> & components, time_t exp )
147147{
148148 std::ostringstream ofs;
149149 ofs << LABELPREFIX;
@@ -155,11 +155,14 @@ Recipient::buildLabel(std::vector<std::pair<std::string_view, std::string_view>>
155155 first = false ;
156156 }
157157 }
158+ if (exp > 0 ) {
159+ ofs << " &server_exp=" << exp;
160+ }
158161 return ofs.str ();
159162}
160163
161164std::string
162- Recipient::BuildLabelEID (int version, EIDType type, std::string_view cn, std::string_view serial_number, std::string_view last_name, std::string_view first_name)
165+ Recipient::BuildLabelEID (int version, EIDType type, std::string_view cn, std::string_view serial_number, std::string_view last_name, std::string_view first_name, time_t exp )
163166{
164167 // In case of cards issued to an organization the first name (and last name) are missing. We ommit these parts.
165168 if (first_name.empty ()) {
@@ -168,7 +171,7 @@ Recipient::BuildLabelEID(int version, EIDType type, std::string_view cn, std::st
168171 {" type" , type_strs[type]},
169172 {" cn" , cn},
170173 {" serial_number" , serial_number}
171- });
174+ }, exp );
172175 } else {
173176 return buildLabel ({
174177 {" v" , std::to_string (version)},
@@ -177,15 +180,15 @@ Recipient::BuildLabelEID(int version, EIDType type, std::string_view cn, std::st
177180 {" serial_number" , serial_number},
178181 {" last_name" , last_name},
179182 {" first_name" , first_name}
180- });
183+ }, exp );
181184 }
182185}
183186
184187std::string
185- Recipient::BuildLabelEID (const std::vector<uint8_t >& cert)
188+ Recipient::BuildLabelEID (const std::vector<uint8_t >& cert, time_t exp )
186189{
187190 Certificate x509 (cert);
188- return BuildLabelEID (CDoc2::KEYLABELVERSION, getEIDType (x509.policies ()), x509.getCommonName (), x509.getSerialNumber (), x509.getSurname (), x509.getGivenName ());
191+ return BuildLabelEID (CDoc2::KEYLABELVERSION, getEIDType (x509.policies ()), x509.getCommonName (), x509.getSerialNumber (), x509.getSurname (), x509.getGivenName (), exp ? exp : x509. getNotAfter () );
189192}
190193
191194std::string
0 commit comments