차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
|
ko:bs2_setsslhandler [2017/06/28 11:51] 127.0.0.1 바깥 편집 |
ko:bs2_setsslhandler [2022/06/29 08:35] (현재) mark [반환값] |
||
|---|---|---|---|
| 줄 23: | 줄 23: | ||
| ==== 반환값 ==== | ==== 반환값 ==== | ||
| 성공적으로 수행될 경우 ''BS_SDK_SUCCESS''를 반환하고, 에러가 발생할 경우 상응하는 에러 코드를 반환합니다. | 성공적으로 수행될 경우 ''BS_SDK_SUCCESS''를 반환하고, 에러가 발생할 경우 상응하는 에러 코드를 반환합니다. | ||
| + | |||
| + | ==== 샘플코드 ==== | ||
| + | C++ | ||
| + | <code cpp> | ||
| + | int BS2Context::setSSLHandler() | ||
| + | { | ||
| + | int sdkResult = BS2_SetSSLHandler(context_, BS2Context::OnPreferMethod, BS2Context::OnGetRootCaFilePath, BS2Context::OnGetServerCaFilePath, BS2Context::OnGetServerPrivateKeyFilePath, BS2Context::OnGetPassword, BS2Context::onErrorOccured); | ||
| + | if (BS_SDK_SUCCESS != sdkResult) | ||
| + | { | ||
| + | TRACE("BS2_SetSSLHandler call failed: %d", sdkResult); | ||
| + | return sdkResult; | ||
| + | } | ||
| + | |||
| + | sdkResult = BS2_SetDeviceSSLEventListener(context_, BS2Context::OnSendRootCA); | ||
| + | if (BS_SDK_SUCCESS != sdkResult) | ||
| + | { | ||
| + | TRACE("BS2_SetDeviceSSLEventListener call failed: %d", sdkResult); | ||
| + | } | ||
| + | |||
| + | return sdkResult; | ||
| + | } | ||
| + | </code> | ||
| + | C# | ||
| + | <code cpp> | ||
| + | if (Util.IsYes()) | ||
| + | { | ||
| + | private API.PreferMethod cbPreferMethod = null; | ||
| + | private API.GetRootCaFilePath cbGetRootCaFilePath = null; | ||
| + | private API.GetServerCaFilePath cbGetServerCaFilePath = null; | ||
| + | private API.GetServerPrivateKeyFilePath cbGetServerPrivateKeyFilePath = null; | ||
| + | private API.GetPassword cbGetPassword = null; | ||
| + | private API.OnErrorOccured cbOnErrorOccured = null; | ||
| + | |||
| + | cbPreferMethod = new API.PreferMethod(PreferMethodHandle); | ||
| + | cbGetRootCaFilePath = new API.GetRootCaFilePath(GetRootCaFilePathHandle); | ||
| + | cbGetServerCaFilePath = new API.GetServerCaFilePath(GetServerCaFilePathHandle); | ||
| + | cbGetServerPrivateKeyFilePath = new API.GetServerPrivateKeyFilePath(GetServerPrivateKeyFilePathHandle); | ||
| + | cbGetPassword = new API.GetPassword(GetPasswordHandle); | ||
| + | cbOnErrorOccured = new API.OnErrorOccured(OnErrorOccuredHandle); | ||
| + | //ServicePointManager.SecurityProtocol = (SecurityProtocolType)SecurityProtocolType.Ssl3; | ||
| + | |||
| + | BS2ErrorCode sdkResult = (BS2ErrorCode)API.BS2_SetSSLHandler(sdkContext, cbPreferMethod, cbGetRootCaFilePath, cbGetServerCaFilePath, cbGetServerPrivateKeyFilePath, cbGetPassword, null); | ||
| + | if (sdkResult != BS2ErrorCode.BS_SDK_SUCCESS) | ||
| + | { | ||
| + | Console.WriteLine("BS2_SetSSLHandler failed with : {0}", sdkResult); | ||
| + | API.BS2_ReleaseContext(sdkContext); | ||
| + | sdkContext = IntPtr.Zero; | ||
| + | return; | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | //bSsl = true; | ||
| + | } | ||
| + | |||
| + | } | ||
| + | </code> | ||
| + | |||