[FAB-7568] Refactor certificate sanitization code
[FAB-7568] Refactor certificate sanitization code

Removing duplications from certificate sanitization, extracting common
peace out of if-then-else statement, since it's being executed
regardless of the if statement value.

Change-Id: I02e28e753abc92d7c47d478d1245ea7bd92b60da
Signed-off-by: Artem Barger <6d127d713cb520aa658cf81ac2373d74ffc1958c@il.ibm.com>

manish-sethi/fabric-sidedb,ckeyer/fabric,xixuejia/fabric,manish-sethi/fabric-sidedb,muralisrini/fabric,binhn/fabric,lukehuangch/fabric,hyperledger/fabric,lukehuangch/fabric,jimthematrix/fabric,manish-sethi/fabric-sidedb,stemlending/fabric,stemlending/fabric,muralisrini/fabric,xixuejia/fabric,ckeyer/fabric,ckeyer/fabric,manish-sethi/fabric-sidedb,lukehuangch/fabric,manish-sethi/fabric-sidedb,lukehuangch/fabric,manish-sethi/fabric-sidedb,muralisrini/fabric,ckeyer/fabric,binhn/fabric,manish-sethi/fabric,manish-sethi/fabric-sidedb,lukehuangch/fabric,jimthematrix/fabric,lukehuangch/fabric,ckeyer/fabric,stemlending/fabric,hyperledger/fabric,lukehuangch/fabric,ckeyer/fabric,stemlending/fabric,manish-sethi/fabric,binhn/fabric,ckeyer/fabric,xixuejia/fabric