Calling CloseOutputFile invalidates return from FindCertificate


Error -8 (Invalid signature number) is returned on a signing method.


Probable Cause


CloseOutputFile was called after the Sign method or after calling FindCertificate.


Resolution


Call CloseOutputFile  before the Sign method and before calling FindCertificate.