Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net: Semantic Kernel. 'The SSL connection could not be established, see inner exception.' #10082

Open
sophialagerkranspandey opened this issue Jan 6, 2025 · 0 comments
Assignees
Labels
.NET Issue or Pull requests regarding .NET code

Comments

@sophialagerkranspandey
Copy link
Contributor

Discussed in #10029

Originally posted by GDT48 December 23, 2024
I am trying Semantic Kernel with OpenAI in a Muai application. I am able to successfully get a simple prompt response using windows. However running under Android (emulator and local device) I get the error Microsoft.SemanticKernel.HttpOperationException: The SSL connection could not be established, see inner exception.

The following is the relevent code block, complete n Entry. Output goes to Label (Answer).

Error is raised at line:

var response = await kernel.InvokePromptAsync(((Entry)sender).Text);

As mentioned above code runs OK on Windows Machine but not on Android.

    public static IKernelBuilder builder = Kernel.CreateBuilder();
    public static Kernel kernel = builder
             .AddOpenAIChatCompletion("gpt-4o-mini", OpenAI_Key)
            .Build();

private async void Question_Completed(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(((Entry)sender).Text))
{
try
{
string request = ((Entry)sender).Text;
ActivityIsRunning = true;
var response = await kernel.InvokePromptAsync(((Entry)sender).Text);
Answer.Text += $"You: {((Entry)sender).Text}{Environment.NewLine}AI: {response.ToString()}{Environment.NewLine}{Environment.NewLine}";
((Entry)sender).Text = string.Empty;

        ActivityIsRunning = false;
    }
    catch (Exception)
    {

        throw;
    }

}

}
Full exception as follows:

{Microsoft.SemanticKernel.HttpOperationException: The SSL connection could not be established, see inner exception.
---> System.ClientModel.ClientResultException: The SSL connection could not be established, see inner exception.
---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception.
---> Interop+AndroidCrypto+SslException: Exception of type 'Interop+AndroidCrypto+SslException' was thrown.
--- End of inner exception stack trace ---
at System.Net.Security.SslStream.d__1501[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(QueueItem queueItem)
at System.Threading.Tasks.TaskCompletionSourceWithCancellation1.d__1[[System.Net.Http.HttpConnection, System.Net.Http, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at System.ClientModel.Primitives.HttpClientPipelineTransport.ProcessSyncOrAsync(PipelineMessage message, Boolean async)
--- End of inner exception stack trace ---
at System.ClientModel.Primitives.HttpClientPipelineTransport.ProcessSyncOrAsync(PipelineMessage message, Boolean async)
at System.ClientModel.Primitives.HttpClientPipelineTransport.ProcessCoreAsync(PipelineMessage message)
at System.ClientModel.Primitives.PipelineTransport.ProcessSyncOrAsync(PipelineMessage message, Boolean async)
at System.ClientModel.Primitives.PipelineTransport.ProcessAsync(PipelineMessage message)
at System.ClientModel.Primitives.PipelineTransport.ProcessAsync(PipelineMessage message, IReadOnlyList1 pipeline, Int32 currentIndex) at System.ClientModel.Primitives.PipelinePolicy.ProcessNextAsync(PipelineMessage message, IReadOnlyList1 pipeline, Int32 currentIndex)
at System.ClientModel.Primitives.ApiKeyAuthenticationPolicy.ProcessAsync(PipelineMessage message, IReadOnlyList1 pipeline, Int32 currentIndex) at System.ClientModel.Primitives.PipelinePolicy.ProcessNextAsync(PipelineMessage message, IReadOnlyList1 pipeline, Int32 currentIndex)
at System.ClientModel.Primitives.ClientRetryPolicy.ProcessSyncOrAsync(PipelineMessage message, IReadOnlyList1 pipeline, Int32 currentIndex, Boolean async) at System.ClientModel.Primitives.ClientRetryPolicy.ProcessSyncOrAsync(PipelineMessage message, IReadOnlyList1 pipeline, Int32 currentIndex, Boolean async)
at System.ClientModel.Primitives.ClientRetryPolicy.ProcessAsync(PipelineMessage message, IReadOnlyList1 pipeline, Int32 currentIndex) at GenericActionPipelinePolicy.ProcessAsync(PipelineMessage message, IReadOnlyList1 pipeline, Int32 currentIndex)
at OpenAI.GenericActionPipelinePolicy.ProcessAsync(PipelineMessage message, IReadOnlyList1 pipeline, Int32 currentIndex) at OpenAI.GenericActionPipelinePolicy.ProcessAsync(PipelineMessage message, IReadOnlyList1 pipeline, Int32 currentIndex)
at System.ClientModel.Primitives.ClientPipeline.SendAsync(PipelineMessage message)
at OpenAI.ClientPipelineExtensions.ProcessMessageAsync(ClientPipeline pipeline, PipelineMessage message, RequestOptions options)
at OpenAI.Chat.ChatClient.CompleteChatAsync(BinaryContent content, RequestOptions options)
at OpenAI.Chat.ChatClient.CompleteChatAsync(IEnumerable1 messages, ChatCompletionOptions options, CancellationToken cancellationToken) at Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.<RunRequestAsync>d__651[[System.ClientModel.ClientResult1[[OpenAI.Chat.ChatCompletion, OpenAI, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b4187f3e65366280]], System.ClientModel, Version=1.1.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8]].MoveNext()
--- End of inner exception stack trace ---
at Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.<RunRequestAsync>d__651[[System.ClientModel.ClientResult1[[OpenAI.Chat.ChatCompletion, OpenAI, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b4187f3e65366280]], System.ClientModel, Version=1.1.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8]].MoveNext()
at Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.GetChatMessageContentsAsync(String targetModel, ChatHistory chat, PromptExecutionSettings executionSettings, Kernel kernel, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.KernelFunctionFromPrompt.GetChatCompletionResultAsync(IChatCompletionService chatCompletion, Kernel kernel, PromptRenderingResult promptRenderingResult, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.KernelFunctionFromPrompt.InvokeCoreAsync(Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken) at Microsoft.SemanticKernel.KernelFunction.<>c__DisplayClass21_0.<<InvokeAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.SemanticKernel.Kernel.InvokeFilterOrFunctionAsync(NonNullCollection1 functionFilters, Func2 functionCallback, FunctionInvocationContext context, Int32 index)
at Microsoft.SemanticKernel.Kernel.OnFunctionInvocationAsync(KernelFunction function, KernelArguments arguments, FunctionResult functionResult, Func2 functionCallback, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.KernelFunction.InvokeAsync(Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)
at OpenAISematicKernal.SimpleResponse.Question_Completed(Object sender, EventArgs e) in C:\VSProjects\OpenAISematicKernalApp\OpenAISematicKernal\Views\SimpleResponse.xaml.cs:line 42}
base: {System.Exception}
RequestMethod: (null)
RequestPayload: (null)
RequestUri: (null)
ResponseContent: (null)
StatusCode: null
I have search the internet and AI for a solution but unable to resolve. As I don't have a problem with running on Windows I'm guessing something Android specific but don't know what.

@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code triage labels Jan 6, 2025
@github-actions github-actions bot changed the title Semantic Kernel. 'The SSL connection could not be established, see inner exception.' .Net: Semantic Kernel. 'The SSL connection could not be established, see inner exception.' Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

No branches or pull requests

3 participants