I am using bouncycastle library to generate the public key.
I am decoding public key like this:
var cf = CertificateFactory.getInstance("X.509");
var certificate = cf.generateCertificate(new ByteArrayInputStream(Base64.getDecoder().decode(base64Certificate)));
where base64Certificate is string generated by bouncycastle (initially in pem format).
I am getting this error:
Unable to initialize, java.io.IOException: Short read of DER length
What am I doing wrong?
I have implemented custom kafkalistenererrorhandler. I want to send the message to retry topic if message fails in processing. For this purpose I have added some headers to it. For doing this I am using spring-meesage.
Issue is when I am sending message using kafkatemplate it adds "\" to the string message.
Following is the code what I am doing.
public Object handleError(Message<?> message, ListenerExecutionFailedException exception) {
logger.info("Enter handleError message");
int numberOfRetries = messageRetryCount(message);
MessageBuilder<?> messageBuilder = MessageBuilder.fromMessage(message).removeHeader(KafkaHeaders.TOPIC)
.removeHeader(KafkaHeaders.PARTITION_ID).removeHeader(KafkaHeaders.MESSAGE_KEY)
.setHeader(KafkaHeaders.TOPIC, numberOfRetries > 0 ? retryTopic : dlqTopic);
template.send(messageBuilder.build());
Internally spring-kafka converts message to producerRecord. which in output adds \ to the string.
2020-03-20 12:25:28.804 INFO 10936 --- [_consumer-0-C-1] c.h.kafkaretry.consumer.SimpleConsumer : in rety :: "\"testfail\""
Does anyone faced same issue ? any alternatives or solution ?
Looks like you use JsonSerializer while your data is just a plain string. Consider to use a StringSerializer or JsonDeserializer on the consumer side.
I am using ejabberd 15.11. While a client is trying to retrieve message from archive getting below error in error logs. My client is sending and receiving encrypted messages
Error log:
[error] <0.2337.0>#gen_iq_handler:process_iq:128
{
{badmatch,{error,{4,<<"not well-formed (invalid token)">>}}},
[
{mod_mam,'-select/8-fun-4-',3,[{file,"src/mod_mam.erl"},{line,681}]},
{lists,map,2,[{file,"lists.erl"},{line,1237}]},
{mod_mam,select,8,[{file,"src/mod_mam.erl"},{line,677}]},
{mod_mam,select_and_send,10,[{file,"src/mod_mam.erl"},{line,577}]},
{gen_iq_handler,process_iq,6,[{file,"src/gen_iq_handler.erl"},{line,127}]},
{gen_iq_handler,handle_info,2,[{file,"src/gen_iq_handler.erl"},{line,171}]},
{gen_server,try_dispatch,4,[{file,"gen_server.erl"},{line,593}]},
{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,659}]}
]
}
crypto:block_encrypt(Type, Key, Ivec, PlainText)is not working insted of it try to use crypto:aes_cfb_128_encrypt(Key, Ivec, PlainText) function.
I'm trying to map different CryptographicExceptions to custom exceptions and messages. For example, "Object already exists" ==> "Not enough permissions to access an existing RSA key container". However, when I examine CryptographicException class, I don't find any error code collection like other exception types have. I'm running on 3.5, so HResult is not available either. Finally, I cannot rely on the message, since it can be localized. Any other ideas?
public Exception GetMappedCryptographicException(CryptographicException e)
{
uint hresult = (uint)Marshal.GetHRForException(e);
switch (hresult)
{
case 0x8009000F; // OBJECT_ALREADY_EXISTS
return new Exception(e, "Not enough permissions to access RSA key container.");
default:
return new Exception(e, "Unexpected cryptographic exception occurred.");
}
}
I am trying to send data to DotNetOpenAuth website as described here http://msdn.microsoft.com/en-us/library/debx8sh9.aspx
Sender receive (500) Internal Server Error. The same code for blank website without DotNetOpenAuth works fine. Should I tweak something?
Here is an exception:
System.ArgumentNullException was unhandled by user code
Message="Value cannot be null.\r\nParameter name: key"
Source="mscorlib"
ParamName="key"
StackTrace:
at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at DotNetOpenAuth.OAuth.ChannelElements.OAuthChannel.ReadFromRequestCore(HttpRequestInfo request) in c:\BuildAgent\work\7ab20c0d948e028f\src\DotNetOpenAuth\OAuth\ChannelElements\OAuthChannel.cs:line 145
at DotNetOpenAuth.Messaging.Channel.ReadFromRequest(HttpRequestInfo httpRequest) in c:\BuildAgent\work\7ab20c0d948e028f\src\DotNetOpenAuth\Messaging\Channel.cs:line 372
at DotNetOpenAuth.OAuth.ServiceProvider.ReadRequest(HttpRequestInfo request) in c:\BuildAgent\work\7ab20c0d948e028f\src\DotNetOpenAuth\OAuth\ServiceProvider.cs:line 222
Exception occurs on last line of the code:
private void context_AuthenticateRequest(object sender, EventArgs e)
{
// Don't read OAuth messages directed at the OAuth controller or else we'll fail nonce checks.
if (this.IsOAuthControllerRequest())
{
return;
}
if (HttpContext.Current.Request.HttpMethod != "HEAD")
{ // workaround: avoid involving OAuth for HEAD requests.
IDirectedProtocolMessage incomingMessage = OAuthServiceProvider.ServiceProvider.ReadRequest(new HttpRequestInfo(this.application.Context.Request));
If you're sending the POST request with a Content-Type of application/x-www-form-urlencoded, but the POST entity contains something other than the normal key1=value1&key2=value2 format, that might explain it. It looks like DotNetOpenAuth can't handle a POST entity that claims to be name=value pairs but only has a value without a key in front of it. Arguably that's a bug in DotNetOpenAuth since normally that's just considered a value of a null key.
If you're not sending key=value pairs at all, I suggest you drop or change the Content-Type header so that you're not claiming to be sending key=value pairs. If you are sending them, but intentionally sending a null key, then hang on while the bug gets fixed.