asp.net core Jwt Tokenl SSL issues
We are running a few aspnet core APIs in a docker swarm with nginx as the reverse proxy server.
We have been running this set up for a while without any issue. However recently we added an SSL certificate that we got from letsencrypt. Since then we notice that after we hit the /api/TokenAuth/Authenticate endpoint and get assign a Bearer token if we try and make a subsequent call using the token that was just assigned, the call sometimes fail and we get a 302 (it works about 40% of the time). It seems that if we try using that same token again after some time has passed than the call works.
It's strange that this only seems to be an issue if we have ssl(https) on.
I cannot replicate the issue locally. It seems to only show up when the api is deployed to our docker swarm (which is running nginx and the api as containers, nginx handles the ssl cert).
Does anyone have any idea what the issue might be? Has anyone experienced something like this before that could point me in the right direction?
There are two console below: The top one is an example of it working and I got the expected results back. The bottom is the response when it fails.
docker nginx asp.net-core asp.net-core-2.0 docker-swarm
add a comment |
We are running a few aspnet core APIs in a docker swarm with nginx as the reverse proxy server.
We have been running this set up for a while without any issue. However recently we added an SSL certificate that we got from letsencrypt. Since then we notice that after we hit the /api/TokenAuth/Authenticate endpoint and get assign a Bearer token if we try and make a subsequent call using the token that was just assigned, the call sometimes fail and we get a 302 (it works about 40% of the time). It seems that if we try using that same token again after some time has passed than the call works.
It's strange that this only seems to be an issue if we have ssl(https) on.
I cannot replicate the issue locally. It seems to only show up when the api is deployed to our docker swarm (which is running nginx and the api as containers, nginx handles the ssl cert).
Does anyone have any idea what the issue might be? Has anyone experienced something like this before that could point me in the right direction?
There are two console below: The top one is an example of it working and I got the expected results back. The bottom is the response when it fails.
docker nginx asp.net-core asp.net-core-2.0 docker-swarm
Looks like "something with caching". So the first thing I'd check is if the request reaches your app. (does your server or nginx respond with 302?). Then it looks as if you do not send any "no cache" headers?
– Christoph Lütjen
Nov 21 '18 at 19:57
add a comment |
We are running a few aspnet core APIs in a docker swarm with nginx as the reverse proxy server.
We have been running this set up for a while without any issue. However recently we added an SSL certificate that we got from letsencrypt. Since then we notice that after we hit the /api/TokenAuth/Authenticate endpoint and get assign a Bearer token if we try and make a subsequent call using the token that was just assigned, the call sometimes fail and we get a 302 (it works about 40% of the time). It seems that if we try using that same token again after some time has passed than the call works.
It's strange that this only seems to be an issue if we have ssl(https) on.
I cannot replicate the issue locally. It seems to only show up when the api is deployed to our docker swarm (which is running nginx and the api as containers, nginx handles the ssl cert).
Does anyone have any idea what the issue might be? Has anyone experienced something like this before that could point me in the right direction?
There are two console below: The top one is an example of it working and I got the expected results back. The bottom is the response when it fails.
docker nginx asp.net-core asp.net-core-2.0 docker-swarm
We are running a few aspnet core APIs in a docker swarm with nginx as the reverse proxy server.
We have been running this set up for a while without any issue. However recently we added an SSL certificate that we got from letsencrypt. Since then we notice that after we hit the /api/TokenAuth/Authenticate endpoint and get assign a Bearer token if we try and make a subsequent call using the token that was just assigned, the call sometimes fail and we get a 302 (it works about 40% of the time). It seems that if we try using that same token again after some time has passed than the call works.
It's strange that this only seems to be an issue if we have ssl(https) on.
I cannot replicate the issue locally. It seems to only show up when the api is deployed to our docker swarm (which is running nginx and the api as containers, nginx handles the ssl cert).
Does anyone have any idea what the issue might be? Has anyone experienced something like this before that could point me in the right direction?
There are two console below: The top one is an example of it working and I got the expected results back. The bottom is the response when it fails.
docker nginx asp.net-core asp.net-core-2.0 docker-swarm
docker nginx asp.net-core asp.net-core-2.0 docker-swarm
asked Nov 21 '18 at 15:30
Taurus OmejiaTaurus Omejia
276
276
Looks like "something with caching". So the first thing I'd check is if the request reaches your app. (does your server or nginx respond with 302?). Then it looks as if you do not send any "no cache" headers?
– Christoph Lütjen
Nov 21 '18 at 19:57
add a comment |
Looks like "something with caching". So the first thing I'd check is if the request reaches your app. (does your server or nginx respond with 302?). Then it looks as if you do not send any "no cache" headers?
– Christoph Lütjen
Nov 21 '18 at 19:57
Looks like "something with caching". So the first thing I'd check is if the request reaches your app. (does your server or nginx respond with 302?). Then it looks as if you do not send any "no cache" headers?
– Christoph Lütjen
Nov 21 '18 at 19:57
Looks like "something with caching". So the first thing I'd check is if the request reaches your app. (does your server or nginx respond with 302?). Then it looks as if you do not send any "no cache" headers?
– Christoph Lütjen
Nov 21 '18 at 19:57
add a comment |
1 Answer
1
active
oldest
votes
I found the issue. We have 3 instances/replica of api that is set to issue the Token. The server time on each server seems to be off by seconds. Therefore if the server that issues the token is ahead of the server that processes the subsequent request, then the token is not valid yet.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53415399%2fasp-net-core-jwt-tokenl-ssl-issues%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I found the issue. We have 3 instances/replica of api that is set to issue the Token. The server time on each server seems to be off by seconds. Therefore if the server that issues the token is ahead of the server that processes the subsequent request, then the token is not valid yet.
add a comment |
I found the issue. We have 3 instances/replica of api that is set to issue the Token. The server time on each server seems to be off by seconds. Therefore if the server that issues the token is ahead of the server that processes the subsequent request, then the token is not valid yet.
add a comment |
I found the issue. We have 3 instances/replica of api that is set to issue the Token. The server time on each server seems to be off by seconds. Therefore if the server that issues the token is ahead of the server that processes the subsequent request, then the token is not valid yet.
I found the issue. We have 3 instances/replica of api that is set to issue the Token. The server time on each server seems to be off by seconds. Therefore if the server that issues the token is ahead of the server that processes the subsequent request, then the token is not valid yet.
answered Nov 21 '18 at 20:59
Taurus OmejiaTaurus Omejia
276
276
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53415399%2fasp-net-core-jwt-tokenl-ssl-issues%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Looks like "something with caching". So the first thing I'd check is if the request reaches your app. (does your server or nginx respond with 302?). Then it looks as if you do not send any "no cache" headers?
– Christoph Lütjen
Nov 21 '18 at 19:57