Token generation failed

Catalin3 months ago

Hello. I have such an error in the logs, can someone help me?

Screenshot 2024-08-29 112754.png

Catalin3 months ago

Hello. Can someone please explain the cause?
Token generation failed

Screenshot 2024-09-02 103202.png

Anton Tananaev3 months ago

Try enabling full stack traces, so we can see full error stack. Also please paste proper text logs instead of screenshots of logs.

Catalin3 months ago
2024-09-03 08:16:46  WARN: Token generation failed - 
java.security.spec.InvalidKeySpecException: java.security.InvalidKeyException: Unable to decode key
    at jdk.crypto.ec/sun.security.ec.ECKeyFactory.engineGeneratePublic(ECKeyFactory.java:156)
    at java.base/java.security.KeyFactory.generatePublic(KeyFactory.java:351)
    at org.traccar.api.signature.CryptoManager.initializeKeys(CryptoManager.java:85)
    at org.traccar.api.signature.CryptoManager.sign(CryptoManager.java:52)
    at org.traccar.api.signature.TokenManager.generateToken(TokenManager.java:73)
    at org.traccar.api.signature.TokenManager.generateToken(TokenManager.java:60)
    at org.traccar.notification.TextTemplateFormatter.prepareContext(TextTemplateFormatter.java:62)
    at org.traccar.notification.NotificationFormatter.formatMessage(NotificationFormatter.java:54)
    at org.traccar.notificators.NotificatorWeb.send(NotificatorWeb.java:55)
    at org.traccar.database.NotificationManager.lambda$updateEvent$3(NotificationManager.java:140)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at org.traccar.database.NotificationManager.lambda$updateEvent$4(NotificationManager.java:133)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at org.traccar.database.NotificationManager.updateEvent(NotificationManager.java:132)
    at org.traccar.database.NotificationManager.updateEvents(NotificationManager.java:176)
    at org.traccar.ProcessingHandler.lambda$processEventHandlers$3(ProcessingHandler.java:174)
    at org.traccar.handler.events.OverspeedEventHandler.analyzePosition(OverspeedEventHandler.java:115)
    at org.traccar.ProcessingHandler.lambda$processEventHandlers$4(ProcessingHandler.java:173)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at org.traccar.ProcessingHandler.processEventHandlers(ProcessingHandler.java:173)
    at org.traccar.ProcessingHandler$1.processed(ProcessingHandler.java:163)
    at org.traccar.handler.DatabaseHandler.handlePosition(DatabaseHandler.java:50)
    at org.traccar.ProcessingHandler$1.processed(ProcessingHandler.java:161)
    at org.traccar.handler.PositionForwardingHandler.handlePosition(PositionForwardingHandler.java:134)
    at org.traccar.ProcessingHandler$1.processed(ProcessingHandler.java:161)
    at org.traccar.handler.EngineHoursHandler.handlePosition(EngineHoursHandler.java:46)
    at org.traccar.ProcessingHandler$1.processed(ProcessingHandler.java:161)
    at org.traccar.handler.ComputedAttributesHandler.handlePosition(ComputedAttributesHandler.java:203)
    at org.traccar.ProcessingHandler$1.processed(ProcessingHandler.java:161)
    at org.traccar.handler.MotionHandler.handlePosition(MotionHandler.java:41)
    at org.traccar.ProcessingHandler$1.processed(ProcessingHandler.java:161)
    at org.traccar.handler.GeocoderHandler.handlePosition(GeocoderHandler.java:72)
    at org.traccar.ProcessingHandler$1.processed(ProcessingHandler.java:161)
    at org.traccar.handler.GeofenceHandler.handlePosition(GeofenceHandler.java:44)
    at org.traccar.ProcessingHandler$1.processed(ProcessingHandler.java:161)
    at org.traccar.handler.FilterHandler.handlePosition(FilterHandler.java:279)
    at org.traccar.ProcessingHandler$1.processed(ProcessingHandler.java:161)
    at org.traccar.handler.DistanceHandler.handlePosition(DistanceHandler.java:74)
    at org.traccar.ProcessingHandler$1.processed(ProcessingHandler.java:161)
    at org.traccar.handler.HemisphereHandler.handlePosition(HemisphereHandler.java:56)
    at org.traccar.ProcessingHandler$1.processed(ProcessingHandler.java:161)
    at org.traccar.handler.OutdatedHandler.handlePosition(OutdatedHandler.java:53)
    at org.traccar.ProcessingHandler.processPositionHandlers(ProcessingHandler.java:156)
    at org.traccar.ProcessingHandler.onReleased(ProcessingHandler.java:150)
    at org.traccar.database.BufferingManager.accept(BufferingManager.java:111)
    at org.traccar.ProcessingHandler.channelRead(ProcessingHandler.java:135)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at org.traccar.handler.network.RemoteAddressHandler.channelRead(RemoteAddressHandler.java:53)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at org.traccar.ExtendedObjectDecoder.channelRead(ExtendedObjectDecoder.java:86)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at org.traccar.WrapperContext.fireChannelRead(WrapperContext.java:102)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)
    at org.traccar.WrapperInboundHandler.channelRead(WrapperInboundHandler.java:57)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
    at org.traccar.handler.network.StandardLoggingHandler.channelRead(StandardLoggingHandler.java:51)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at org.traccar.handler.network.NetworkMessageHandler.channelRead(NetworkMessageHandler.java:37)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1407)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:918)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:994)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.security.InvalidKeyException: Unable to decode key
    at java.base/sun.security.x509.X509Key.decode(X509Key.java:375)
    at jdk.crypto.ec/sun.security.ec.ECPublicKeyImpl.<init>(ECPublicKeyImpl.java:77)
    at jdk.crypto.ec/sun.security.ec.ECKeyFactory.implGeneratePublic(ECKeyFactory.java:223)
    at jdk.crypto.ec/sun.security.ec.ECKeyFactory.engineGeneratePublic(ECKeyFactory.java:152)
    ... 85 more
Caused by: java.io.IOException: extra data at the end
    at java.base/sun.security.util.DerValue.<init>(DerValue.java:432)
    at java.base/sun.security.util.DerValue.<init>(DerValue.java:344)
    at java.base/sun.security.x509.X509Key.decode(X509Key.java:373)
    ... 88 more
Anton Tananaev3 months ago

Looks like something is wrong with the signing keys. If you're ok with resetting them, you can clear the tc_keystore table.

Catalin3 months ago

Thanks for the answer, but I have a question, if I make an alter table tc_keystore, will it somehow affect the operation of the system and will the data be lost or not? because I have over 300 cars with data

Anton Tananaev3 months ago

Data won't be lost, but old API tokens will be invalid.