“Invalid signature file” when attempting to run a .jar

后端 未结 21 2251
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 05:34

My java program is packaged in a jar file and makes use of an external jar library, bouncy castle. My code compiles fine, but running the jar leads to the following error:

21条回答
  •  执笔经年
    2020-11-22 06:14

    A strategy would consist in using ANT to simplify the removal of the signature from each Jar file. It would proceed with the following steps:

    1. Copying the MANIFEST.MF in a temporary file
    2. Removing the Name and SHA entries from the temporary file
    3. Creating a temporary Jar file with the temporary manifest
    4. Removing the temporary manifest
    5. Swapping the original Jar file with the temporary one

    Here is an ANT macrodef doing the work:

    
        
        
    
            
                
                    
                
            
    
            
            
    
            
                
                    
                    
                    
                    
                
            
    
            
    
            
    
    

    `

    The definition can then be called this way in an ANT task:

    
        
    
    

提交回复
热议问题