protected ICredentials SanitizeCredentials(ICredentials credentials) { String accessKeyId = credentials.GetAccessKeyId(); String secretKey = credentials.GetSecretKey(); if (secretKey != null) { secretKey = secretKey.Trim(); } if (accessKeyId != null) { accessKeyId = accessKeyId.Trim(); } return(new BasicCredentials(accessKeyId, secretKey)); }