當談到使用證書進行身份驗證時,我是一個新手。如果我的問題沒有意義,請糾正我。我在哪裏可以找到我在本地創建的X.509證書的詳細信息?
我在本地創建了2048位X.509證書。我有server.crt,server.key,server.key.org和mycert.pfx(mycert.pfx包含公鑰和私鑰,我在我的代碼中使用該文件)。
現在我做我有下面的代碼的Java應用程序:
String tenant="f6377xxx-aeb2-4a8a-be8a-7xxxxa60be3";
String authority = "https://login.windows.net/"+tenant+"/oauth2/authorize";
ExecutorService service=null;
service= Executors.newFixedThreadPool(1);
try
{
AuthenticationContext authenticationContext =
new AuthenticationContext(authority,false,service);
String certFile="/projects/mycert.pfx";
InputStream pkcs12Cert= new SharedFileInputStream(certFile);
AsymmetricKeyCredential credential = AsymmetricKeyCredential.create(
"xxxx-e53c-45b7-432-7b91d93674b6", pkcs12Cert, "password");
Future<AuthenticationResult> future = authenticationContext.acquireToken(
"https://outlook.office365.com", credential, null);
System.out.println("Token Received"+future.get().getAccessToken());
String token=future.get().getAccessToken();
此代碼試圖將Office驗證365 API。爲此,我使用tenant id和其他信息創建了一個Azure應用程序。現在上面的代碼會引發下面的異常。
com.microsoft.aad.adal4j.AuthenticationException:{ 「ERROR_DESCRIPTION」:「AADSTS70002:錯誤驗證憑據AADSTS50012:。客戶端斷言包含無效的簽名[原因 - 鍵沒有被發現,關鍵的指紋客戶使用:'H6383KO9763C6E4KIE8363032D6',配置的密鑰:[]] \ r \ nTrace ID:76YT3GG-7b8b-JDU73-afeb-JDUEY7372 \ r \ n相關性ID:7H3Y743-a5b7-KD98-88ba-HDUYE7663 \ r \ n時間戳:2016 -08-31 23:56:50Z「,」error「:」invalid_client「}
原因是因爲我沒有在服務器端上傳證書(即在Azure AD應用程序上)。我跟着this tutorial,發現一個解決方案,顯示我必須下載清單文件,使用證書對其進行編輯,然後將其上載到Azure服務器。
問題是我不知道從證書中獲取以下密鑰的值。你能幫我找到customKeyIdentifier
,keyId
和value
嗎?
"keyCredentials": [
{
"customKeyIdentifier": "$base64Thumbprint_from_above",
"keyId": "$keyid_from_above",
"type": "AsymmetricX509Cert",
"usage": "Verify",
"value": "$base64Value_from_above"
}
],
您開發的平臺是什麼(我假設它不是Windows,因爲您鏈接的工具向您展示瞭如何使用PowerShell獲取這些值)。 –
定義'本地創建'。 – EJP
@PhilippeSignoret我正在構建一個將調用O365 API的Java Batch Job。我在Mac上開發,但批處理將在Unix服務器之一中運行。 EJP,我使用Openssl在本地開發機器上創建了證書,並且它是自簽名的。這僅用於開發目的。 – WowBow