我正在尝试使用Java APNS(一个开源项目)向iPhone发送推送通知.但是我收到了一个错误.
我使用.pem文件作为证书.这应该是.p12文件吗?我不确定区别是什么,但我在网上看到这些文件格式之间存在差异.
这是代码:
ApnsService service =
APNS.newService()
.withCert("gpk.pem", "XXXX")
.withSandboxDestination()
.build();
String payload = APNS.newPayload().alertBody("Can't be simpler than this!").build();
String token = "theTokenIsRemoveHere";
service.push(token, payload);
Run Code Online (Sandbox Code Playgroud)
这是错误:
Exception in thread "main" com.notnoop.exceptions.InvalidSSLConfig: java.io.IOException: toDerInputStream rejects tag type 45
at com.notnoop.apns.internal.Utilities.newSSLContext(Utilities.java:102)
at com.notnoop.apns.ApnsServiceBuilder.withCert(ApnsServiceBuilder.java:161)
at com.notnoop.apns.ApnsServiceBuilder.withCert(ApnsServiceBuilder.java:124)
at com.geomobsters.cli.ApnsClient.main(ApnsClient.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.io.IOException: toDerInputStream rejects tag type 45
at sun.security.util.DerValue.toDerInputStream(DerValue.java:806)
at com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1201)
at java.security.KeyStore.load(KeyStore.java:1185)
at com.notnoop.apns.internal.Utilities.newSSLContext(Utilities.java:87)
... 8 more
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Google App Engine Web应用程序将UTF-8编码的文本发送回浏览器.我这样写,写这个:
byte[] utf8Bytes = "æøå".getBytes("UTF-8");
Run Code Online (Sandbox Code Playgroud)
当我在本地执行此操作时,我得到一个包含6个字节的字节数组.当我在Google App Engine上执行此操作时,我得到一个包含12个字节的数组.很奇怪,是吗?
有谁知道为什么?
我已经成功地从GAE编写UTF-8编码文本,通过自己编码字节,然后写回原始字节.像这样:
output.write(new byte[]{(byte)0xc3, (byte)0xa5, (byte) 0xc3, (byte)0xa6, (byte)0xc3, (byte)0xb8 });
Run Code Online (Sandbox Code Playgroud)
这实际上是有效的.但是,有没有人能够回答为什么String在GAE上的编码方式不同于本地?
注意:通过unicode转义编码字符有效 - 如下所示:
byte[] utf8Bytes = "\u00E5\u00F8\u00E6".getBytes("UTF-8");
Run Code Online (Sandbox Code Playgroud) 我有一个HTML页面,当调整浏览器窗口大小时,它使用CSS和JavaScript将页面内容置于浏览器中间.
当我使用标准HTML5 Doctype声明时,所有浏览器都完全忽略我的CSS文件.我不知道为什么.当我删除HTML5 Doctype时,它们再次正常工作.该页面在Chrome,FF和IE中显示相同(不正确).一切都错了.
这是页面的开头:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/stylesheet-mobile.jsp" >
<link rel="stylesheet" type="text/css" href="/stylesheet-mobile-frontpage.jsp" >
<meta name="viewport" content="width=device-width" />
<script src="/javascript/jquery/jquery-1.8.3.min.js"></script>
<script src="/javascript/resize-fit.jsp"></script>
<link rel="shortcut icon" href="/favicon.ico" />
</head>
Run Code Online (Sandbox Code Playgroud)
有线索吗?