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

Exception is thrown with the exmple private-claims.cpp #351

Closed
gggamemaster opened this issue Jun 2, 2024 · 10 comments · Fixed by #348
Closed

Exception is thrown with the exmple private-claims.cpp #351

gggamemaster opened this issue Jun 2, 2024 · 10 comments · Fixed by #348
Labels

Comments

@gggamemaster
Copy link

What's your question?

it raise a exception

Additional Context

the other example,i can run its well except example\partial-claim-verifier.cpp,because i do not install nlohmann-json。and why private-claims.cpp run fail?
image
image

@prince-chrismc
Copy link
Collaborator

What message does the exception print?

They were not meant to be running a debugger. They are likely just expiring

.set_expires_at(time + sec{15} + min{2})

You should also check the call stack to see which verification function is failing, it's another way then reading the messages.

@gggamemaster
Copy link
Author

image
it seems time Expire?
89dd4fa218574dffc765dcc5fd0379e

@gggamemaster
Copy link
Author

.set_expires_at(time + sec{15} + min{2}) menas that the token will time expire after 2 min 15 sec???just few time the exception araise..

@gggamemaster
Copy link
Author

@Thalhammer

@prince-chrismc
Copy link
Collaborator

prince-chrismc commented Jun 3, 2024

I'ts very difficult to see pictures, please keep the screenshot for the IDE. It's hard to follow with your language settings. It be great if you changed it to English (or french or german).

You can add

try {
verifier.verify(decoded);
std::cout << "Success!" << std::endl;
} catch (const std::exception& ex) { std::cout << "Error: " << ex.what() << std::endl; }

And this will print a message that will make ot easier to know what error you are getting.

Error 14 (I assume it's token verification)

token_expired,

Do get the exception if you run the code outside of the debugger?

@gggamemaster
Copy link
Author

you are right ,print "token expired" after i add the code on windows environment.

@gggamemaster
Copy link
Author

i run private-claims.cpp fail in vs2022 debug 64 and vs2017 relaese64

@Thalhammer
Copy link
Owner

Thats pretty odd, ngl. The example sets a expiration of 1h and there should be no way he is halting the program for more than an hour (except on purpose) to debug it.

The example seems to work fine on godbolt (or at least it did with the 0.7 release, I don't add master to godbolt).

@prince-chrismc
Copy link
Collaborator

prince-chrismc commented Jun 3, 2024

The examples built last week with #348 so I dont think anything broke. Might be some localization with the time?

@prince-chrismc
Copy link
Collaborator

Oh that example is not ran in CI... 😡

.set_not_before(time + sec{15})

Is wrong that should be minus 15 seconds not plus.

@prince-chrismc prince-chrismc changed the title i meet a question when i run the exmple code private-claims.cpp Exception is thrown with the exmple private-claims.cpp Jun 3, 2024
prince-chrismc added a commit to prince-chrismc/jwt-cpp that referenced this issue Jun 3, 2024
@prince-chrismc prince-chrismc linked a pull request Jun 6, 2024 that will close this issue
prince-chrismc added a commit that referenced this issue Jun 15, 2024
* dev container + vscode extensions

* exploring cmake presets for CI

* ignore user presets

* add configure to build preset

windows ran in debug, which means the multi config needs more help

* coverage preset

* creating a fuzzing preset

* fuzzing fix cwd + more configs to preset

* move cmake set vars to right section

https://learn.microsoft.com/en-us/cpp/build/cmake-presets-vs?view=msvc-170

"You can set C and C++ compilers by using cacheVariables.CMAKE_C_COMPILER and cacheVariables.CMAKE_CXX_COMPILER in a Configure Preset. It's equivalent to passing -D CMAKE_C_COMPILER=<value> and -D CMAKE_CXX_COMPILER=<value> to CMake from the command line."

* fix workdir for new fuzz run targets

* split up presets into more files

* fix include order (liking this less)

* add asan to presets

* fix copy paste

* add asan build preset

* move ubsan to presets

* replace mustache with a cmake script

* touch ups

* restore file to void merge conflicts

* fix order for args

* remove action wrapper

more quotes for inputs

* revert bad render of boost_json

* fix casing

* format changes

* test to see if output is working

* last try

* git revert moving mustache to cmake

* cmake not enough for presets

* drop ci prefix

* new test for `library_ROOT` search path

* install with presets

* cmake --install does not take a preset

* install with preset is not yet supported

https://gitlab.kitware.com/cmake/cmake/-/issues/23208

* add missing build step

* more global fuzzing flags to toolchain file

* fixup toolchain in presets

* fix pathing and limit configs to tested platforms

* clean up + use presets for clang-tidy

* dry up sanitizer flags

* try install with a preset

* remove duplicated test

* notes about hunter test

* skip checking the compiler since this causes errors with the same CMake uses in combinations with the fuzz sanitizer flag

https://github.com/prince-chrismc/jwt-cpp/actions/runs/7481024827/job/20361722539?pr=33

```
    /usr/bin/ld: /usr/bin/ld: DWARF error: invalid or unhandled FORM value: 0x22
    CMakeFiles/cmTC_ff7c6.dir/testCCompiler.c.o: in function `main':
    testCCompiler.c:(.text.main[main]+0x0): multiple definition of `main'; /usr/lib/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerMain.cpp.o):(.text.main+0x0): first defined here
    /usr/bin/ld: /usr/lib/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerMain.cpp.o): in function `main':
    (.text.main+0x12): undefined reference to `LLVMFuzzerTestOneInput'
```

* remove system name to disable cross compiling

* tests do not pass clang-tidy

* drop toolchain, use target specific flags

* leave flags in cmake

* missing deps + clean apt files

* remove some code duplication

* fix typo

* devcontainers fix, test and add wolfssl

refactored installer to have a script that could be reused

* add missing build context

* pass version to script

* dont use bash syntax

* fix typo

* upload tar.gz for new releases

* revert name to manually trigger it

* Update and rename nuget.yml to release.yml

* disable nuget for testing

* add a zip as well

* back to basics

* remove remove testing code

* update workflow name

* enable testing needs to be in the root

* add a test preset and use it in some workflows

* fix linting tests

* bump github actions

* bump python setup

* drop dev containers

* dont install openssl on windows

* revert merge conflicts

* fix whitespace

* fix private claims example to have a valid token

#351

* put back versioned format

I dont remember why, it looks like it was debugging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants