More certificate factory code