Fix a bug in registering certificates