com.groupdocs.signature.exception.GroupDocsSignatureException: com.groupdocs.signature.exception.GroupDocsSignatureException: Specified argument was out of the range of valid values

I am using groupdocs signature as java API. When used for Java projects in a window environment, digital signature add-ons were possible. But when i use this in Linux OS, com.groupdocs.signature.exception.GroupDocsSignatureException: com.groupdocs.signature.exception.GroupDocsSignatureException: Specified argument was out of the range of valid values.This error occurred… The groupdocs version I am using is 23.4 and is in the ubuntu 20.04 environment. What’s the problem? From here, it’s my code. @Override
public void signPdf(String filename) throws Exception {

    try {

        System.out.print(" 디지털서명함수 check 1 filename도 같이 잘넘어왔나?"+filename +" /");


        //로컬용 경로
        //String filePath = "src/main/resources/static/certPdfFile/";

        //배포용 경로
        String filePath = "/metainfiles/";

        Signature signature = new Signature(filePath + "converted.pdf");
        System.out.print(" / 디지털서명함수 check 2" + signature);



        //String certPath = "src/main/resources/certification/"; - 로컬용
        String certPath = "/certification/";  //-배포용

// 디지털 서명 옵션 정의

        //DigitalSignOptions options = new DigitalSignOptions(certPath + "metainssl.der");
        DigitalSignOptions options = new DigitalSignOptions(certPath + "metainssl.pfx");

        System.out.print(" / 디지털서명함수 check 3" + options);
        options.setPassword("12345678900");
        options.setVisible(true);
        options.setImageFilePath( filePath + "metain-sign-Image.png");
        options.setWidth(80);
        options.setHeight(80);
        options.setLeft(370);
        options.setTop(650);
        options.setPageNumber(1);
        System.out.print("지장크기확인 : 높이 :" + options.getHeight() + " , 넓이 : " + options.getWidth());
        System.out.print(" / 디지털서명함수 check 4" + options);
        System.out.print(" 디지털서명함수 check 5 / ");

        // 파일에 문서 서명
        signature.sign(filePath + filename, options);
        System.out.print(" 디지털서명함수 check 6 FINAL / ");
    } catch (Exception e) {
        System.out.print("에러기록 : " + e.toString());
        throw new GroupDocsSignatureException(e.toString());
    }


}//signPdf
1 Like

Is it a certificate issue? I tried to apply the certificate to both the pfx extension file and the der extension file encoded with der, but the same error occurs.

@seoyyy

We apologize for any inconvenience caused. To assist you better, could you kindly provide us with the problematic/source files, such as the PDF and the certificate? This will enable us to conduct a thorough investigation and address the issue. Thank you for your cooperation.

com.groupdocs.signature.exception.GroupDocsSignatureException: com.groupdocs.signature.exception.GroupDocsSignatureException: java.lang.NullPointerException
at com.metain.web.service.CertificationServiceImpl.signPdf(CertificationServiceImpl.java:314)
at com.metain.web.service.CertificationServiceImpl$$FastClassBySpringCGLIB$$ad362e85.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:89)
at com.metain.web.config.LogConfig.logging(LogConfig.java:32)
at jdk.internal.reflect.GeneratedMethodAccessor45.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:624)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:72)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
at com.metain.web.service.CertificationServiceImpl$$EnhancerBySpringCGLIB$$874427c9.signPdf()
at com.metain.web.controller.CertificationController.convertToPdf(CertificationController.java:195)
at com.metain.web.controller.CertificationController$$FastClassBySpringCGLIB$$1d064f35.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:89)
at com.metain.web.config.LogConfig.logging(LogConfig.java:32)
at jdk.internal.reflect.GeneratedMethodAccessor45.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:624)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:72)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
at com.metain.web.controller.CertificationController$$EnhancerBySpringCGLIB$$20e9c8e6.convertToPdf()
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1072)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:965)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:681)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:228)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:337)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:81)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:122)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:116)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:126)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:81)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:109)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:149)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:147)
at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:223)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:217)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:132)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:112)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:82)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.session.DisableEncodeUrlFilter.doFilterInternal(DisableEncodeUrlFilter.java:42)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:221)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:186)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163)
at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:126)
at org.springframework.boot.web.servlet.support.ErrorPageFilter.access$000(ErrorPageFilter.java:64)
at org.springframework.boot.web.servlet.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:101)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1723)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:829)
에러기록 : com.groupdocs.signature.exception.GroupDocsSignatureException: com.groupdocs.signature.exception.GroupDocsSignatureException: java.lang.NullPointerException2023-06-20 10:17:57.651 INFO 1 — [nio-9000-exec-4] com.metain.web.config.LogConfig : -----------> RESPONSE : com.metain.web.controller.CertificationController(convertToPdf) = null (9807ms)

@Override
public void signPdf(String filename) throws Exception {
try {

        //Path of pdf file to include digital signature and path to be saved after digital signature
        //String filePath = "src/main/resources/static/certPdfFile/"; //Path for developement

        //Path when deployed as a docker container in a ubuntu environment
        String filePath = "/metainfiles/";

        

        
        //String certPath = "src/main/resources/certification/"; //certification Path for developement
//certification Path for deployment
        String certPath = "/certification/";  

Signature signature = new Signature(filePath + "converted.pdf");

        //DigitalSignOptions options = new DigitalSignOptions(certPath + "metacert.pfx");

        String certPath = "src/main/resources/certification/";
        DigitalSignOptions options = new DigitalSignOptions(certPath + "metain.pfx");

      
        options.setPassword("12345678900");
        options.setVisible(true);
        options.setImageFilePath("src/main/resources/certPdfFile/metain-sign-Image.png");
        options.setWidth(80);
        options.setHeight(80);
        options.setLeft(370);
        options.setTop(650);
        options.setPageNumber(1);
      
    
        signature.sign(filePath + filename, options);  // the error occured here

    } catch (Exception e) {
        System.out.print(e.toString());
        throw new GroupDocsSignatureException(e.toString());
    }

}//signPdf

The metain.pfx certificate file was generated in the X509 method and der encoded. When running locally, the digital signature is completed because the certificate is valid, but in order to distribute it, the certificate is placed in a folder inside the project, built and distributed as a war file, and it also says that the file is invalid.

com.groupdocs.signature.exception.GroupDocsSignatureException: com.groupdocs.signature.exception.GroupDocsSignatureException: Digital certificate for X509Certificate2 has wrong format. Description: Can’t find file: src/main/resources/certification/metaincert.pfx.

And when a certificate of type x509 is created in the ubuntu environment to be distributed, a volume is mounted inside the docker container, and the certificate is recognized, a nullException appears and digital signature fails.

Please let me know if I need to provide more information about the code or error

I have one more question. What exactly is the type of certificate available in groupdocs signature? When I generate a certificate from Linux to openssl, can you tell me what form of certificate should I make, what extension should I have, and what encoding should go in

@seoyyy

We appreciate you sharing the details. Kindly allow us some time to thoroughly investigate the issue. Thank you for your patience.

Thank you. Let me ask you one more question. Should the certificate format be different from that in Windows to use this on Linux? What type should I create in certificate format or encoding?

com.groupdocs.signature.exception.GroupDocsSignatureException: Specified argument was out of the range of valid values.
Parameter name: Parameter name: index
When do I get this error? What’s the problem?

@seoyyy

You should make .pfx.
However, to reproduce this issue at our end, we need following details from you:

  • Source document
  • Problematic certificate file
  • Steps to reproduce the issue on Linux

groupdocs_signature.7z (5.0 KB)
groupdocs_signature.zip (6.0 KB)

1 Like

com.groupdocs.signature.exception.GroupDocsSignatureException: Specified argument was out of the range of valid values.
Parameter name: Parameter name: index
When do I get this error? What’s the problem?

@seoyyy

Thank you for providing us with the details. We kindly request your patience as we investigate and replicate the issue on our end. Once we have completed our analysis, we will promptly provide you with a suitable solution. Thank you for your understanding.

Hi, @seoyyy! Thank you for providing details and source code. Please be aware that a digital certificate for signing requires private and public keys. So far it seems the attached digital certificate file has no private key.

signature_javanet-certificate_issue01.png (82.3 KB)

Can you please double-check check on the following?

  • create PFX file with private and public key
  • try to sign it the same way.

One more, can you please share how did you compose this provided PFX certificate file?
Thank you!

Hi @seoyyy,
Few more updates - actually PFX certificate is a common standard so it should work in any OS no matter under which OS / or tool this digital certificate was created.
THank you!

thank you for your help. By the way, it works on windowsos, but it always doesn’t work when I put that code in a container on Linux ec2. So I have a few questions.
When does this error occur? The .sign method produces this error. com.groupdocs.signature.exception.GroupDocsSignatureException: com.groupdocs.signature.exception.GroupDocsSignatureException: Specified argument was out of the range of valid values.
com.groupdocs.signature.exception.GroupDocsSignatureException: com.groupdocs.signature.exception.GroupDocsSignatureException: Specified argument was out of the range of valid values.
Parameter name: Parameter name: index

And how do I configure the PFX certificate file?

openssl genpkey -algorithm RSA -out private.key
openssl rsa -pubout -in private.key -out public.key
openssl req -new -x509 -key private.key -out certificate.crt
openssl pkcs12 -export -out certificate.pfx -inkey private.key -in certificate.crt

I created a pfx file like this. Is it right?