보안 채널 계층 예제
다음 예제에서는 채널 계층 보안을 보여 줍니다.
TCP를 통해 Windows 전송 보안: 클라이언트: RequestReplyTcpClientWithWindowsTransportSecurityExample, 서버: RequestReplyTcpServerWithWindowsTransportSecurityExample.
명명된 파이프를 통해 Windows 전송 보안: 클라이언트: RequestReplyNamedPipesClientWithWindowsTransportSecurityExample, 서버: RequestReplyNamedPipesServerWithWindowsTransportSecurityExample.
SSL 전송 보안: 클라이언트: HttpClientWithSslExample, 서버: HttpServerWithSslExample.
SSL 혼합 모드 보안에 대한 사용자 이름: 클라이언트: HttpClientWithUsernameOverSslExample, Server: HttpServerWithUsernameOverSslExample.
SSL 혼합 모드 보안에 대한 사용자 이름: 클라이언트: HttpClientWithKerberosOverSslExample, Server: HttpServerWithKerberosOverSslExample.
SSL 혼합 모드 보안에 대한 사용자 이름: MetadataImportWithUsernameOverSslExample. SSL 혼합 모드 보안을 통해 발급된 토큰: MetadataImportWithIssuedTokenOverSslExample. SSL 혼합 모드 보안을 통해 X509 인증서: MetadataImportWithX509OverSslExample.
보안 샘플에 대한 One-Time 설정
WWSAPI 보안 예제를 실행하려면 SSL에 대한 클라이언트 및 서버 인증서와 HTTP 헤더 인증을 위한 로컬 사용자 계정을 설정해야 합니다. 시작하기 전에 다음 도구가 필요합니다.
- MakeCert.exe(Windows 7 SDK에서 사용 가능)
- CertUtil.exe 또는 CertMgr.exe(CertUtil.exe는 Windows Server 2003부터 Windows SDK에서 사용할 수 있습니다. CertMgr.exe Windows 7 SDK에서 사용할 수 있습니다. 이러한 도구 중 하나만 필요합니다.)
- HttpCfg.exe: (Windows 2003 또는 Windows XP를 사용하는 경우에만 필요합니다. 이 도구는 Windows XP SP2 지원 도구에서 사용할 수 있으며 Windows Server 2003 리소스 키트 도구 CD와 함께 제공됩니다.)
Windows 7 SDK를 설치하여 WWSAPI 예제를 가져오는 경우 %ProgramFiles%\Microsoft SDKs\Windows\v7.0\bin에서 MakeCert.exe 및 CertMgr.exe 찾을 수 있습니다.
명령 프롬프트에서 다음 5단계 설정을 수행합니다(Windows Vista 이상을 사용하는 경우 상승됨).
- 자체 서명된 인증서를 CA(인증 기관) 또는 발급자로 생성합니다. MakeCert.exe -ss 루트 -sr LocalMachine -n "CN=Fake-Test-CA" -cy 기관 -r -sk "CAKeyContainer"
- 이전 인증서를 발급자로 사용하여 서버 인증서 생성: MakeCert.exe -ss My -sr LocalMachine -n "CN=localhost" -sky exchange -is Root -ir LocalMachine -in Fake-Test-CA -sk "ServerKeyContainer"
- 다음 명령 중 하나를 실행하여 서버 인증서의 지문(40자 SHA-1 해시)을 찾고 발급자 Fake-Test-CA를 사용하여 localhost라는 인증서를 검색합니다.
- 내 localhost CertUtil.exe -store
- CertMgr.exe -s -r 내
- HTTP.SYS 공백 없이 서버 인증서의 지문을 등록합니다.
- Windows Vista 이상에서("appid" 옵션은 임의 GUID) Netsh.exe http add sslcert ipport=0.0.0.0:8443 appid={00001 111-aaaa-2222-bbbb-3333cccc4444} certhash=<40CharacterThumbprint>
- Windows XP 또는 2003: HttpCfg.exe ssl -i 0.0.0.0:8443 -h <40CharacterThumbprint>
- 로컬 사용자 만들기: Net 사용자 "TestUserForBasicAuth" "TstPWD@*4Bsic" /add
인증서, SSL 인증서 바인딩 및 이전 단계에서 만든 사용자 계정을 정리하려면 다음 명령을 실행합니다. 동일한 이름의 인증서가 여러 대 있는 경우 CertMgr.exe 삭제하기 전에 입력이 필요합니다.
- CertMgr.exe -del -c -n Fake-Test-CA -s -r LocalMachine 루트
- localhost -s -r localMachine My CertMgr.exe -del -c -n
- Netsh.exe http delete sslcert ipport=0.0.0.0:8443(또는 ssl -i 0.0.0.0:8443 삭제 HttpCfg.exe)
- Net 사용자 "TestUserForBasicAuth" /delete
Fake-Test-CA라는 루트 인증서가 하나만 있는지 확인합니다. 확실하지 않은 경우 5단계 설정을 시작하기 전에 위의 정리 명령을 사용하여 이러한 인증서를 정리하고 오류를 무시하는 것이 안전합니다.