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

Bouncy Castle - support for 3.1 #8

Closed
Faisal0sal opened this issue Mar 7, 2020 · 13 comments
Closed

Bouncy Castle - support for 3.1 #8

Faisal0sal opened this issue Mar 7, 2020 · 13 comments
Labels
wontfix This will not be worked on

Comments

@Faisal0sal
Copy link

Warning NU1701: Package 'BouncyCastle 1.8.5' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project. (NU1701)

@alexalok
Copy link
Owner

alexalok commented Mar 7, 2020

Hi!

.NET Core apps can consume .NET Framework library, albeit their functionality may be limited when used like that.

In our case, however, the required functionality works as expected, so you may safely ignore the warning. It shouldn't prevent you from building and running your application.

@Faisal0sal
Copy link
Author

@alexalok Thank you for your response, I was going to use as you said anyway. But I'm trying to add services.AddApns();

And it says that there is no reference for it.

@alexalok
Copy link
Owner

alexalok commented Mar 7, 2020

It seems that you've referenced the main dotAPNS package. Instead, you should reference dotAPNS.AspNetCore package, which contains code that integrates dotAPNS with ASP.NET Core projects.

Also, if you reference dotAPNS.AspNetCore, you can safely remove the reference to dotAPNS as it is implicitly added to the project anyway.

@Faisal0sal
Copy link
Author

Thank you so much. One more thing, when using the certificate we do need to specify the password. How would we do that after CreateUsingCert

@Faisal0sal
Copy link
Author

I have created another certificate with no password, then faced this issue:

An error occurred while sending the request.
---> System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'SslStream'.

@alexalok
Copy link
Owner

alexalok commented Mar 7, 2020

Please provide a code sample that you have issues with. Note that ApnsClient.CreateUsingCert has an overload allowing you to pass X509Certificate2 object, which you can construct from an arbitrary certificate, even the one that has a password (see this for reference).

@Faisal0sal
Copy link
Author

Faisal0sal commented Mar 7, 2020

Well, I have been able to work with the certificate issue. Only this issue is now I'm facing:

An error occurred while sending the request. ---> System.ObjectDisposedException: Cannot access a disposed object. Object name: 'SslStream'.

`// POST
// Send Notifications
// KeyId {}
[HttpPost("notify")]
public async Task sendNotificationAsync()
{
string ErrorMessage = null;
string private_key_path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Cert/AppleCertificateWalaaDev.p12");
var cert = new X509Certificate2(private_key_path, "");
var push = ApplePush
.CreateContentAvailable()
.AddToken("12b5bb89699ca2a0068f4b01444d0cc49670c489b8e661c37e9029de3101141c");

        ApnsResponse response = await ApnsService.SendPush(push, cert);

        return Json(ApiResponse.GetResponse(HttpContext, 200));
    }`

@alexalok
Copy link
Owner

alexalok commented Mar 7, 2020

I see. Could you please provide a full stack trace of an exception? Right now I'm not entirely sure as to what can be the cause of the issue you're facing.

@Faisal0sal
Copy link
Author

System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.ObjectDisposedException: Cannot access a disposed object. Object name: 'SslStream'. at System.Net.Security.SslStream.ThrowIfExceptional() at System.Net.Security.SslStream.CheckThrow(Boolean authSuccessCheck, Boolean shutdownCheck) at System.Net.Security.SslStream.ReadAsync(Memory1 buffer, CancellationToken cancellationToken)
at System.Net.Http.Http2Connection.ReadAtLeastAsync(Stream stream, Memory1 buffer, Int32 minReadBytes) at System.Net.Http.Http2Connection.EnsureIncomingBytesAsync(Int32 minReadBytes) at System.Net.Http.Http2Connection.ReadFrameAsync(Boolean initialFrame) at System.Net.Http.Http2Connection.ProcessIncomingFramesAsync() --- End of inner exception stack trace --- at System.Net.Http.Http2Connection.SendHeadersAsync(HttpRequestMessage request, CancellationToken cancellationToken, Boolean mustFlush) at System.Net.Http.Http2Connection.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at dotAPNS.ApnsClient.Send(ApplePush push)
at WalaaWalletPass.Controllers.PassHandler.sendNotificationAsync() in /Users/fmalsalamah/Projects/wallet-pass-db/CreativeTim.Argon.DotNetCore.Free/Controllers/PassHandler.cs:line 111
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

@Faisal0sal
Copy link
Author

Issue is not happening anymore once I have set sandbox to true

@alexalok
Copy link
Owner

alexalok commented Mar 7, 2020

According to the stack trace, I can see that the actual exception happens somewhere inside the HttpClient that dotAPNS uses to make HTTP/2 requests.
Unfortunately, there is no clear sign of what can be causing the issue.

If possible, create a separate project with the minimum code that reproduces the issue and send it to me at contact@alexalok.me
If you do so, please be sure to include the certificate you are using as well, as I do not have any .p12 certificates to test with. I will make sure to delete it after we resolve the issue.

Another option would be to switch to a token-based connection. If you have the proper rights in the Apple Developer Account, I highly suggest to do so as the certificate-based HTTP/2 connection support overall seems to be quite quirky in .NET (see #3, #4).

@alexalok
Copy link
Owner

Hi, @Faisal0sal, just checking if you still need an assistance. If you're all up and running, perhaps the issue can be closed?
Please note that if there is no answer from your side the issue will be closed in a few days.

@alexalok
Copy link
Owner

The issue is closed due to the lack of feedback.

@alexalok alexalok added the wontfix This will not be worked on label Mar 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants