+ logger::note( "FINE: Public Key successfully copied from Request." );
+
+ {
+ logger::note( "INFO: Determining Validity Period ..." );
+ std::time_t from, to;
+ std::time_t now = time( 0 );
+ std::pair<bool, std::time_t> parsed;
+
+ if( ( parsed = parseDate( cert->wishFrom ) ).first /* is of yyyy-mm-dd */ ) {
+ if( parsed.second > now ) {
+ from = parsed.second;
+ } else { // fail
+ from = now;
+ }
+ } else {
+ from = now;
+ }
+
+ if( ( ( from - now ) > /* 2 Weeks */ ( 2 * 7 * 24 * 60 * 60 ) ) || ( ( now - from ) >= 0 ) ) {
+ from = now;
+ }
+
+ if( ( parsed = parseDate( cert->wishTo ) ).first /*is of yyyy-mm-dd */ ) {
+ if( parsed.second > from ) {
+ to = parsed.second;
+ } else {
+ to = from + /*2 Years */ 2 * 365 * 24 * 60 * 60;
+ }
+ } else if( ( parsed = parseYearInterval( from, cert->wishTo ) ).first /*is of [0-9]+y */ ) {
+ to = parsed.second;
+ } else if( ( parsed = parseMonthInterval( from, cert->wishTo ) ).first /*is of [0-9]+m */ ) {
+ to = parsed.second;
+ } else {
+ to = from + /*2 Years */ 2 * 365 * 24 * 60 * 60;
+ }
+
+ time_t limit = prof.maxValidity;
+
+ if( ( to - from > limit ) || ( to - from < 0 ) ) {
+ to = from + limit;
+ }
+
+ c.setTimes( from, to );
+ logger::note( "FINE: Setting validity period successful:" );
+ {
+ struct tm* timeobj;
+ std::vector<char> timebuf;
+
+ timeobj = gmtime( &from );
+ timebuf.resize( 128 );
+ timebuf.resize( std::strftime( const_cast<char*>( timebuf.data() ), timebuf.size(), "%F %T %Z", timeobj ) );
+ logger::note( "FINE: - Valid not before: ", std::string( timebuf.cbegin(), timebuf.cend() ) );
+
+ timeobj = gmtime( &to );
+ timebuf.resize( 128 );
+ timebuf.resize( std::strftime( const_cast<char*>( timebuf.data() ), timebuf.size(), "%F %T %Z", timeobj ) );
+ logger::note( "FINE: - Valid not after: ", std::string( timebuf.cbegin(), timebuf.cend() ) );
+ }
+ }