trustFrameworkKeySet:uploadPkcs12
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
Upload将 PKCS12 格式密钥 (PFX) trustFrameworkKeyset。 输入是 Pfx 证书内容的 Base64 编码值。 此方法返回 trustFrameworkKey。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
TrustFrameworkKeySet.ReadWrite.All |
| 委派(个人 Microsoft 帐户) |
不支持。 |
| 应用程序 |
TrustFrameworkKeySet.ReadWrite.All |
HTTP 请求
POST /trustFramework/keySets/{id}/uploadPkcs12
| 名称 |
说明 |
| Authorization |
Bearer {token}。必需。 |
| Content-type |
application/json. Required. |
请求正文
在请求正文中,提供具有以下参数的 JSON 对象。
| 参数 |
类型 |
说明 |
| Key |
String |
这是用于发送 pfx 内容的字段。 该值应为实际证书内容的 Base64 编码版本。 |
| 密码 |
String |
这是用于将密码发送到 PFX 内容的字段。 |
响应
如果成功,此方法在响应 200 OK 正文中返回 响应代码和新 trustFrameworkKey 对象。
示例
请求
下面展示了示例请求。
POST https://graph.microsoft.com/beta/trustFramework/keySets/{id}/uploadPkcs12
Content-type: application/json
{
"key": "Base64-encoded-pfx-content",
"password": "password-value"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var key = "Base64-encoded-pfx-content";
var password = "password-value";
await graphClient.TrustFramework.KeySets["{trustFrameworkKeySet-id}"]
.UploadPkcs12(key,password)
.Request()
.PostAsync();
const options = {
authProvider,
};
const client = Client.init(options);
const trustFrameworkKey = {
key: 'Base64-encoded-pfx-content',
password: 'password-value'
};
await client.api('/trustFramework/keySets/{id}/uploadPkcs12')
.version('beta')
.post(trustFrameworkKey);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/trustFramework/keySets/{id}/uploadPkcs12"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
NSString *key = @"Base64-encoded-pfx-content";
payloadDictionary[@"key"] = key;
NSString *password = @"password-value";
payloadDictionary[@"password"] = password;
NSData *data = [NSJSONSerialization dataWithJSONObject:payloadDictionary options:kNilOptions error:&error];
[urlRequest setHTTPBody:data];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
String key = "Base64-encoded-pfx-content";
String password = "password-value";
graphClient.trustFramework().keySets("{id}")
.uploadPkcs12(TrustFrameworkKeySetUploadPkcs12ParameterSet
.newBuilder()
.withKey(key)
.withPassword(password)
.build())
.buildRequest()
.post();
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.New()
key := "Base64-encoded-pfx-content"
requestBody.SetKey(&key)
password := "password-value"
requestBody.SetPassword(&password)
trustFrameworkKeySetId := "trustFrameworkKeySet-id"
result, err := graphClient.TrustFramework().KeySetsById(&trustFrameworkKeySetId).UploadPkcs12(trustFrameworkKeySet-id).Post(requestBody)
Import-Module Microsoft.Graph.Identity.SignIns
$params = @{
Key = "Base64-encoded-pfx-content"
Password = "password-value"
}
Invoke-MgUploadTrustFrameworkKeySetPkcs12 -TrustFrameworkKeySetId $trustFrameworkKeySetId -BodyParameter $params
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"kid": "kid-value",
"use": "sig",
"kty": "OCT",
"nbf": 1508969811,
"exp": 1508973711
}