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

[Native Image] GSS context is not getting initialized in native image #9805

Open
2 tasks
yogeshkumargeek opened this issue Oct 2, 2024 · 3 comments
Open
2 tasks
Assignees

Comments

@yogeshkumargeek
Copy link

Describe the Issue

I wanted to use the GSS context for kerberos token verification.
The normal gradlew run is working correctly with micronaut and I am able to authenticate the token
But , not able to do it in the native Image

Using the latest version of GraalVM can resolve many issues.

GraalVM Version

OpenJDK Runtime Environment GraalVM CE 21.0.2+13.1

Operating System and Version

linux

Diagnostic Flag Confirmation

  • I tried the -H:ThrowMissingRegistrationErrors= flag.

Run Command

./gradlew nativeCompile

Expected Behavior

Gsscontext should be initalized

Actual Behavior

21:28:18.451 [default-nioEventLoopGroup-1-4] ERROR i.m.http.server.RouteExecutor - Unexpected error occurred: null
java.lang.NullPointerException: null
        at java.security.jgss@21.0.2/sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:339)
        at java.security.jgss@21.0.2/sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:303)

Steps to Reproduce

buildArgs.add('--verbose')
buildArgs.add('--strict-image-heap')
buildArgs.add('--add-opens java.base/java.lang=ALL-UNNAMED') //for reflection
buildArgs.add('--enable-native-access')
buildArgs.add('-Dsun.security.jgss.native=true')
buildArgs.add('-H:AdditionalSecurityProviders=sun.security.jgss.SunProvider')
buildArgs.add('-H:IncludeResourceBundles=sun.security.util.Resources')
buildArgs.add('-H:+EnableSecurityServicesFeature')

Additional Context

No response

Run-Time Log Output and Error Messages

No response

@yogeshkumargeek
Copy link
Author

Linked issue : #9778

@oubidar-Abderrahim oubidar-Abderrahim self-assigned this Oct 4, 2024
@oubidar-Abderrahim
Copy link
Member

Hi, Please provide a reproducer to this issue

@yogeshkumargeek
Copy link
Author

Hi , @oubidar-Abderrahim ,
When we are running the micronaut application, using ./gradlew run , we are able to get the GSS context and authenticate the token

But when creating a native executable using ./gradlew nativeCompile
args used in build.gradle

buildArgs.add('--verbose')
buildArgs.add('--strict-image-heap')
buildArgs.add('--add-opens java.base/java.lang=ALL-UNNAMED') //for reflection
buildArgs.add('--enable-native-access')
buildArgs.add('-Dsun.security.jgss.native=true')
buildArgs.add('-H:AdditionalSecurityProviders=sun.security.jgss.SunProvider')
buildArgs.add('-H:IncludeResourceBundles=sun.security.util.Resources')
buildArgs.add('-H:+EnableSecurityServicesFeature')

Then we are seeing this error :

21:28:18.451 [default-nioEventLoopGroup-1-4] ERROR i.m.http.server.RouteExecutor - Unexpected error occurred: null
java.lang.NullPointerException: null
        at java.security.jgss@21.0.2/sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:339)
        at java.security.jgss@21.0.2/sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:303)

Code :

import org.ietf.jgss.GSSContext;
import org.ietf.jgss.GSSCredential;
import org.ietf.jgss.GSSException;
import org.ietf.jgss.GSSManager;
import org.ietf.jgss.GSSName;

GSSManager gssManager = GSSManager.getInstance();   
GSSContext gssContext = gssManager.createContext((GSSCredential)null);   Not able to set context here 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants