factored out acquire server credential code to function acquireServerCredential

Signed-off-by: abbr <wenfred@gmail.com>