在 Windows XP 專業版環境下,使用 WSHttpBinding 搭配 Message 安全模式與 UserName 客戶端認證時,雖已配置服務端憑證與自訂 UserNamePasswordValidator,仍遭遇異常:
The caller was not authenticated by the service.
服務端驗證邏輯正確,帳密比對無誤,但通訊仍失敗。
WCF Message 安全模式要求服務端憑證必須被客戶端信任。XP 非網域環境下,自我簽署憑證預設不受信任,導致訊息層安全交換階段即失敗,根本未進入使用者名稱驗證邏輯。
makecert -r -pe -n "CN=FrankWCFServer" -ss My -sky exchange
FrankWCFServer,點選「匯出」

mmc.exe → 「檔案」 → 「新增/移除嵌入式管理單元」 → 加入「憑證」 → 選「電腦帳戶」 → 「本機電腦」
重新啟動服務宿主與客戶端,輸入正確帳密,呼叫成功。
<serviceCredentials>
<serviceCertificate x509FindType="FindBySubjectName" findValue="MyServer" storeLocation="CurrentUser"/>
<clientCertificate>
<authentication certificateValidationMode="None"/>
</clientCertificate>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="WCFService.MyUserNamePasswordValidator,WCFService"/>
</serviceCredentials>
XP 工作群組環境下開發 WCF Message 安全服務,服務端憑證必須被客戶端機器信任。將自我簽署憑證匯入「受信任的根憑證授權單位」是最快捷的解決路徑,避免架設 CA 或購買商業憑證,適合學習與測試階段。