Creating a certification from a rule

After adding the items to the entity, you probably need to do a context.saveObject(entity); call to update the persisted entity with your changes.

As to the NPE, turning trace logging on for your rule should help narrow down where in the rule that might be occurring (and whether or not the NPE is from your rule or some other process). Sharing the NPE stacktrace should help as well.