Fixed bug with throwing error in generate certificates method

Fixed bug with throwing error in generate certificates method